diff options
author | flu0r1ne <flu0r1ne@flu0r1ne.net> | 2021-07-22 00:41:30 -0500 |
---|---|---|
committer | flu0r1ne <flu0r1ne@flu0r1ne.net> | 2021-07-22 00:41:30 -0500 |
commit | af8f52e2e4c879935656dd93c2fb564c6e2ce515 (patch) | |
tree | 81498b5f6d84d69fd6a9d83e413b95e1dce7b6c4 /cmd/list.go | |
parent | fb8aee6c5147b8751a3920f613934d90b79ef4c5 (diff) | |
download | zsu-af8f52e2e4c879935656dd93c2fb564c6e2ce515.tar.xz zsu-af8f52e2e4c879935656dd93c2fb564c6e2ce515.zip |
Parse within subcommands
Diffstat (limited to 'cmd/list.go')
-rw-r--r-- | cmd/list.go | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/cmd/list.go b/cmd/list.go index d2b9a03..99d5f24 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -1,8 +1,8 @@ package cmd import ( - "flag" "fmt" + "flag" ) func List(params []string) { @@ -10,12 +10,28 @@ func List(params []string) { var withPaths bool - const WITH_PATHS_HELP = "print paths to the provided reference within the snapshot" + withName := aliasedBoolVar( + flags, + &withPaths, + false, + "print paths to the provided reference within the snapshot", + ) - flags.BoolVar(&withPaths, "paths", false, WITH_PATHS_HELP); - flags.BoolVar(&withPaths, "p", false, WITH_PATHS_HELP); + withName("paths") + withName("p") flags.Parse(params); + if(flags.NArg() == 0) { + die.Fatal("Reference file is required") + } + + if(flags.NArg() > 1) { + die.Fatal("Too many arguments provided") + } + + reference := flags.Arg(0) + + fmt.Printf(reference) fmt.Printf("Your flag is: %t", withPaths); } |