Debian Codegraph @

flagtest/flagtest.go

raw symbols SCIP
1 // mauflag - An extendable command-line argument parser for Golang
2 // Copyright (C) 2016 Maunium
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 package main
18
19 import (
20 "fmt"
21 flag "maunium.net/go/mauflag"
22 )
23
24 var bf = flag.Make().LongKey("bff").ShortKey("b").Usage("Change the variable 'bf'").Bool()
25 var xb = flag.Make().ShortKey("x").Usage("Set the boolean X").UsageCategory("XYZ").Bool()
26 var yb = flag.Make().ShortKey("y").Usage("Set the boolean Y").UsageCategory("XYZ").Bool()
27 var zb = flag.Make().ShortKey("z").Usage("Set the boolean Z").UsageCategory("XYZ").Bool()
28 var str = flag.Make().LongKey("this-is-a-string").ShortKey("s").ShortKey("i").Usage("Set a string value").String()
29 var array = flag.Make().LongKey("array").ShortKey("a").LongKey("arr").Usage("Add values to an array").StringArray()
30 var def = flag.Make().LongKey("asd").Default("lorem").Usage("Change a variable").String()
31
32 func main() {
33 flag.MakeHelpFlag()
34 flag.SetHelpTitles("flagtest - Test the mauflag package", "mauflag [-b] [-x] [-y] [-z] [-s STRING] [-a ARRAY VALUE] [--asd STRING]")
35 fmt.Println(flag.Parse())
36
37 if flag.CheckHelpFlag() {
38 return
39 }
40
41 fmt.Println(*bf, *xb, *yb, *zb)
42 fmt.Println(*str)
43 fmt.Println(*def)
44 for _, arg := range *array {
45 fmt.Print(arg, ", ")
46 }
47 fmt.Print("\n")
48 for _, arg := range flag.Args() {
49 fmt.Print(arg, ", ")
50 }
51 fmt.Print("\n")
52 }