main: fix the output if a wrong or none command provided

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2025-02-17 15:37:04 -05:00
parent 9b8dbd620c
commit 01e8a6e859
Signed by: vbatts
GPG key ID: E30EFAA812C6E5ED

13
main.go
View file

@ -15,12 +15,11 @@ import (
func main() { func main() {
cmd := &cli.Command{ cmd := &cli.Command{
Name: "too-soon", Name: "too-soon",
Usage: "check if something expires too soon", Usage: "check if certificates expire too soon",
Version: "0.1", Version: "0.1",
Authors: []any{ Authors: []any{
&mail.Address{Name: "Vincent Batts", Address: "vbatts@hashbangbash.com"}, &mail.Address{Name: "Vincent Batts", Address: "vbatts@hashbangbash.com"},
}, },
DefaultCommand: "pem",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.IntFlag{ &cli.IntFlag{
Name: "days", Name: "days",
@ -42,10 +41,16 @@ func main() {
}, },
Commands: []*cli.Command{ Commands: []*cli.Command{
&cli.Command{ &cli.Command{
Name: "pem", Name: "pem",
Action: fPEMCheck, Usage: "check if PEM certificate files expire too soon",
Action: fPEMCheck,
ArgsUsage: "[PEM files...]",
}, },
}, },
Action: func(ctx context.Context, cmd *cli.Command) error {
cli.ShowAppHelpAndExit(cmd, 1)
return nil
},
} }
if err := cmd.Run(context.Background(), os.Args); err != nil { if err := cmd.Run(context.Background(), os.Args); err != nil {