Skip to content

Commit

Permalink
fix: set exit status and improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
telemachus committed Jan 20, 2025
1 parent 5e515d2 commit 7a8ba61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions internal/cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ func (cmd *cmdEnv) subCmdFrom(args []string) error {
// There should be no extra arguments.
extraArgs := fs.Args()
if len(extraArgs) != 0 {
return fmt.Errorf("unrecognized arguments: %+v", extraArgs)
cmd.exitVal = exitFailure
var s string
if len(extraArgs) > 1 {
s = "s"
}
return fmt.Errorf("unrecognized argument%s: %+v", s, extraArgs)
}

return nil
Expand All @@ -119,7 +124,7 @@ func (cmd *cmdEnv) subCmdUsage(subCmdName string) {
case "sync":
fmt.Print(syncUsage)
default:
fmt.Printf("%s %s: unrecognized subcommand %q\n", cmd.name, cmd.subCmdName, subCmdName)
fmt.Fprintf(os.Stderr, "%s %s: unrecognized subcommand %q\n", cmd.name, cmd.subCmdName, subCmdName)
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/cli/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func subCmdClone(cmd *cmdEnv) {
if err := cmd.subCmdFrom(cmd.subCmdArgs); err != nil {
fmt.Fprintf(os.Stderr, "%s %s: %s", cmd.name, cmd.subCmdName, err)
fmt.Fprintf(os.Stderr, "%s %s: %s\n", cmd.name, cmd.subCmdName, err)
return
}
rs := cmd.repos()
Expand Down

0 comments on commit 7a8ba61

Please sign in to comment.