diff options
author | Slack Coder <slackcoder@server.ky> | 2022-05-20 15:59:02 -0500 |
---|---|---|
committer | Slack Coder <slackcoder@server.ky> | 2022-05-20 15:59:02 -0500 |
commit | d0f06ff4ef35fd54910c686cb2727a08b3fb89cd (patch) | |
tree | 027c85d7526876211740be6c8f494855d9f5c607 /cmd/installpkg/main.go | |
parent | a1e7249e712bfc7bbcf6275bdd87f2343d60f81a (diff) | |
download | pkgtools-go-d0f06ff4ef35fd54910c686cb2727a08b3fb89cd.tar.xz |
add help flag to commands
Display command usage using the '--help' flag.
Diffstat (limited to 'cmd/installpkg/main.go')
-rw-r--r-- | cmd/installpkg/main.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/cmd/installpkg/main.go b/cmd/installpkg/main.go index 5cc4955..009a2e7 100644 --- a/cmd/installpkg/main.go +++ b/cmd/installpkg/main.go @@ -44,6 +44,10 @@ import ( // the previous package's files, and this will catch the few // corner cases without generating unnecessary writes. +func usage() { + getopt.PrintUsage(os.Stdout) +} + func ParseFlags() *pkgtools.InstallPkgFlags { flags := pkgtools.DefaultInstallPkgFlags flags.SetEnvValues() @@ -56,9 +60,12 @@ func ParseFlags() *pkgtools.InstallPkgFlags { } func main() { + getopt.SetParameters("package_filename ...") + help := getopt.BoolLong("help", 0, "display help") + flags := ParseFlags() - if len(getopt.Args()) == 0 { - getopt.PrintUsage(os.Stdout) + if len(getopt.Args()) == 0 || *help { + usage() return } |