Skip to content

Commit

Permalink
Merge pull request #33 from invopop/cmd-bug-fix
Browse files Browse the repository at this point in the history
Fixing bug on cmd
  • Loading branch information
Menendez6 authored Jun 19, 2024
2 parents c45bf6d + 8e11e80 commit cd6036c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ For details on support for converting Addendas, please see the [addendas package
The GOBL to CFDI tool also includes a command line helper. You can find pre-built [gobl.cfdi binaries](https://github.com/invopop/gobl.cfdi/releases) in the github repository, or install manually in your Go environment with:

```bash
go install github.com/invopop/gobl.cfdi
go install ./cmd/gobl.cfdi
```

Usage is very straightforward:

```bash
gobl.cfdi convert ./test/data/invoice.json
gobl.cfdi convert ./test/data/invoice-b2b-bare.json
```

Which should produce something like:
Expand Down
6 changes: 5 additions & 1 deletion cmd/gobl.cfdi/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func convert(o *rootOpts) *convertOpts {

func (c *convertOpts) cmd() *cobra.Command {
cmd := &cobra.Command{
Use: "convert [infile] [outfile]",
Use: "convert <infile> [outfile]",
Short: "Convert a GOBL JSON into a CFDI XML document for Mexico",
RunE: c.runE,
}
Expand All @@ -31,6 +31,10 @@ func (c *convertOpts) cmd() *cobra.Command {
func (c *convertOpts) runE(cmd *cobra.Command, args []string) error {
// ctx := commandContext(cmd)

if len(args) == 0 || len(args) > 2 {
return fmt.Errorf("expected one or two arguments, the command usage is `gobl.cfdi convert <infile> [outfile]`")
}

input, err := openInput(cmd, args)
if err != nil {
return err
Expand Down

0 comments on commit cd6036c

Please sign in to comment.