|
|
@ -24,7 +24,7 @@ func TestParser(t *testing.T) {
|
|
|
|
"pies", "-eat", "--wat", "hello", "mario",
|
|
|
|
"pies", "-eat", "--wat", "hello", "mario",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{
|
|
|
|
Prog: &argh.CommandConfig{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
"e": {},
|
|
|
|
"e": {},
|
|
|
@ -98,8 +98,8 @@ func TestParser(t *testing.T) {
|
|
|
|
"pies", "--wat", "hello", "mario", "-eat",
|
|
|
|
"pies", "--wat", "hello", "mario", "-eat",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: func() argh.CommandConfig {
|
|
|
|
Prog: func() *argh.CommandConfig {
|
|
|
|
cmdCfg := argh.CommandConfig{
|
|
|
|
cmdCfg := &argh.CommandConfig{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
"e": {Persist: true},
|
|
|
|
"e": {Persist: true},
|
|
|
@ -193,7 +193,7 @@ func TestParser(t *testing.T) {
|
|
|
|
name: "one positional arg",
|
|
|
|
name: "one positional arg",
|
|
|
|
args: []string{"pizzas", "excel"},
|
|
|
|
args: []string{"pizzas", "excel"},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{NValue: 1},
|
|
|
|
Prog: &argh.CommandConfig{NValue: 1},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expPT: []argh.Node{
|
|
|
|
expPT: []argh.Node{
|
|
|
|
&argh.Command{
|
|
|
|
&argh.Command{
|
|
|
@ -219,7 +219,7 @@ func TestParser(t *testing.T) {
|
|
|
|
name: "many positional args",
|
|
|
|
name: "many positional args",
|
|
|
|
args: []string{"pizzas", "excel", "wildly", "when", "feral"},
|
|
|
|
args: []string{"pizzas", "excel", "wildly", "when", "feral"},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{
|
|
|
|
Prog: &argh.CommandConfig{
|
|
|
|
NValue: argh.OneOrMoreValue,
|
|
|
|
NValue: argh.OneOrMoreValue,
|
|
|
|
ValueNames: []string{"word"},
|
|
|
|
ValueNames: []string{"word"},
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -267,7 +267,7 @@ func TestParser(t *testing.T) {
|
|
|
|
name: "long value-less flags",
|
|
|
|
name: "long value-less flags",
|
|
|
|
args: []string{"pizzas", "--tasty", "--fresh", "--super-hot-right-now"},
|
|
|
|
args: []string{"pizzas", "--tasty", "--fresh", "--super-hot-right-now"},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{
|
|
|
|
Prog: &argh.CommandConfig{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
"tasty": {},
|
|
|
|
"tasty": {},
|
|
|
@ -312,7 +312,7 @@ func TestParser(t *testing.T) {
|
|
|
|
"--please",
|
|
|
|
"--please",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{
|
|
|
|
Prog: &argh.CommandConfig{
|
|
|
|
Commands: &argh.Commands{Map: map[string]argh.CommandConfig{}},
|
|
|
|
Commands: &argh.Commands{Map: map[string]argh.CommandConfig{}},
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
@ -391,7 +391,7 @@ func TestParser(t *testing.T) {
|
|
|
|
name: "short value-less flags",
|
|
|
|
name: "short value-less flags",
|
|
|
|
args: []string{"pizzas", "-t", "-f", "-s"},
|
|
|
|
args: []string{"pizzas", "-t", "-f", "-s"},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{
|
|
|
|
Prog: &argh.CommandConfig{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
"t": {},
|
|
|
|
"t": {},
|
|
|
@ -429,7 +429,7 @@ func TestParser(t *testing.T) {
|
|
|
|
name: "compound short flags",
|
|
|
|
name: "compound short flags",
|
|
|
|
args: []string{"pizzas", "-aca", "-blol"},
|
|
|
|
args: []string{"pizzas", "-aca", "-blol"},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{
|
|
|
|
Prog: &argh.CommandConfig{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
"a": {},
|
|
|
|
"a": {},
|
|
|
@ -484,7 +484,7 @@ func TestParser(t *testing.T) {
|
|
|
|
name: "mixed long short value flags",
|
|
|
|
name: "mixed long short value flags",
|
|
|
|
args: []string{"pizzas", "-a", "--ca", "-b", "1312", "-lol"},
|
|
|
|
args: []string{"pizzas", "-a", "--ca", "-b", "1312", "-lol"},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{
|
|
|
|
Prog: &argh.CommandConfig{
|
|
|
|
Commands: &argh.Commands{Map: map[string]argh.CommandConfig{}},
|
|
|
|
Commands: &argh.Commands{Map: map[string]argh.CommandConfig{}},
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
@ -549,7 +549,7 @@ func TestParser(t *testing.T) {
|
|
|
|
name: "nested commands with positional args",
|
|
|
|
name: "nested commands with positional args",
|
|
|
|
args: []string{"pizzas", "fly", "freely", "sometimes", "and", "other", "times", "fry", "deeply", "--forever"},
|
|
|
|
args: []string{"pizzas", "fly", "freely", "sometimes", "and", "other", "times", "fry", "deeply", "--forever"},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{
|
|
|
|
Prog: &argh.CommandConfig{
|
|
|
|
Commands: &argh.Commands{
|
|
|
|
Commands: &argh.Commands{
|
|
|
|
Map: map[string]argh.CommandConfig{
|
|
|
|
Map: map[string]argh.CommandConfig{
|
|
|
|
"fly": argh.CommandConfig{
|
|
|
|
"fly": argh.CommandConfig{
|
|
|
@ -632,7 +632,7 @@ func TestParser(t *testing.T) {
|
|
|
|
name: "compound flags with values",
|
|
|
|
name: "compound flags with values",
|
|
|
|
args: []string{"pizzas", "-need", "sauce", "heat", "love", "-also", "over9000"},
|
|
|
|
args: []string{"pizzas", "-need", "sauce", "heat", "love", "-also", "over9000"},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{
|
|
|
|
Prog: &argh.CommandConfig{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
"a": {NValue: argh.ZeroOrMoreValue},
|
|
|
|
"a": {NValue: argh.ZeroOrMoreValue},
|
|
|
@ -735,7 +735,7 @@ func TestParser(t *testing.T) {
|
|
|
|
name: "command specific flags",
|
|
|
|
name: "command specific flags",
|
|
|
|
args: []string{"pizzas", "fly", "--freely", "fry", "--deeply", "-wAt", "hugs"},
|
|
|
|
args: []string{"pizzas", "fly", "--freely", "fry", "--deeply", "-wAt", "hugs"},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{
|
|
|
|
Prog: &argh.CommandConfig{
|
|
|
|
Commands: &argh.Commands{
|
|
|
|
Commands: &argh.Commands{
|
|
|
|
Map: map[string]argh.CommandConfig{
|
|
|
|
Map: map[string]argh.CommandConfig{
|
|
|
|
"fly": argh.CommandConfig{
|
|
|
|
"fly": argh.CommandConfig{
|
|
|
@ -835,7 +835,7 @@ func TestParser(t *testing.T) {
|
|
|
|
name: "total weirdo",
|
|
|
|
name: "total weirdo",
|
|
|
|
args: []string{"PIZZAs", "^wAT@golf", "^^hecKing", "goose", "bonk", "^^FIERCENESS@-2"},
|
|
|
|
args: []string{"PIZZAs", "^wAT@golf", "^^hecKing", "goose", "bonk", "^^FIERCENESS@-2"},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{
|
|
|
|
Prog: &argh.CommandConfig{
|
|
|
|
Commands: &argh.Commands{
|
|
|
|
Commands: &argh.Commands{
|
|
|
|
Map: map[string]argh.CommandConfig{
|
|
|
|
Map: map[string]argh.CommandConfig{
|
|
|
|
"goose": argh.CommandConfig{
|
|
|
|
"goose": argh.CommandConfig{
|
|
|
@ -910,7 +910,7 @@ func TestParser(t *testing.T) {
|
|
|
|
name: "windows like",
|
|
|
|
name: "windows like",
|
|
|
|
args: []string{"hotdog", "/f", "/L", "/o:ppy", "hats"},
|
|
|
|
args: []string{"hotdog", "/f", "/L", "/o:ppy", "hats"},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{
|
|
|
|
Prog: &argh.CommandConfig{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
"f": {},
|
|
|
|
"f": {},
|
|
|
@ -957,7 +957,7 @@ func TestParser(t *testing.T) {
|
|
|
|
name: "invalid bare assignment",
|
|
|
|
name: "invalid bare assignment",
|
|
|
|
args: []string{"pizzas", "=", "--wat"},
|
|
|
|
args: []string{"pizzas", "=", "--wat"},
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
cfg: &argh.ParserConfig{
|
|
|
|
Prog: argh.CommandConfig{
|
|
|
|
Prog: &argh.CommandConfig{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Flags: &argh.Flags{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
Map: map[string]argh.FlagConfig{
|
|
|
|
"wat": {},
|
|
|
|
"wat": {},
|
|
|
|