Skip to content

Commit

Permalink
add cli pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
aburdulescu committed Dec 12, 2023
1 parent 10a441b commit a336e46
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions internal/cli/cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cmd

import (
"flag"
"fmt"
"os"
)

type Cmd struct {
// command name
Name string

// short usage message to be used in the app
Short string

// long usage message
Long string

// flag set
Flags *flag.FlagSet
}

func (c *Cmd) Init() {
if c.Name == "" {
panic("cmd: missing Name")
}
c.Flags = flag.NewFlagSet(c.Name, flag.ContinueOnError)
c.Flags.Usage = func() {
fmt.Fprint(os.Stderr, c.Long)
c.Flags.PrintDefaults()
}
}

0 comments on commit a336e46

Please sign in to comment.