Compare commits

...

2 Commits

Author SHA1 Message Date
Matthew Huxtable bcb35d823a
Merge 8cec7ec8e1 into a4a282cd49 2024-04-26 10:16:01 -07:00
Matthew Huxtable 8cec7ec8e1 cmd/gitops-pusher: improve error on invalid subcommand
Aid diagnosis of invalid subcommands passed to the gitops-pusher,
particularly in the context of CI where the cause of the error is
non-obvious; an invalid subcommand previously rendered the following
error:

terminal command () doesn't define an Exec function

Fixes #11842.

Signed-off-by: Matthew Huxtable <git@tigermatt.uk>
2024-04-23 12:41:18 +01:00
1 changed files with 9 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import (
"context"
"crypto/sha256"
"encoding/json"
"errors"
"flag"
"fmt"
"log"
@ -216,6 +217,14 @@ func main() {
}
if err := root.Parse(os.Args[1:]); err != nil {
if noexec := (ffcli.NoExecError{}); errors.As(err, &noexec) {
if args := noexec.Command.FlagSet.Args(); len(args) > 0 {
log.Fatalf("invalid subcommand %s, see -help for available subcommands", args[0])
} else {
log.Fatal("missing subcommand, see -help for available subcommands")
}
}
log.Fatal(err)
}