reproduce sub command bug
This commit is contained in:
parent
2f2ff270a9
commit
e24ae2ec88
|
@ -20,6 +20,9 @@ func TestCompleter_Complete(t *testing.T) {
|
||||||
"-flag1": PredictAnything,
|
"-flag1": PredictAnything,
|
||||||
"-flag2": PredictNothing,
|
"-flag2": PredictNothing,
|
||||||
},
|
},
|
||||||
|
Sub: Commands{
|
||||||
|
"sub11": {},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"sub2": {
|
"sub2": {
|
||||||
Flags: Flags{
|
Flags: Flags{
|
||||||
|
@ -28,6 +31,11 @@ func TestCompleter_Complete(t *testing.T) {
|
||||||
},
|
},
|
||||||
Args: PredictFiles("*.md"),
|
Args: PredictFiles("*.md"),
|
||||||
},
|
},
|
||||||
|
"sub3": {
|
||||||
|
Sub: Commands{
|
||||||
|
"sub3": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Flags: Flags{
|
Flags: Flags{
|
||||||
"-o": PredictFiles("*.txt"),
|
"-o": PredictFiles("*.txt"),
|
||||||
|
@ -47,7 +55,7 @@ func TestCompleter_Complete(t *testing.T) {
|
||||||
{
|
{
|
||||||
line: "cmd ",
|
line: "cmd ",
|
||||||
point: -1,
|
point: -1,
|
||||||
want: []string{"sub1", "sub2"},
|
want: []string{"sub1", "sub2", "sub3"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
line: "cmd -",
|
line: "cmd -",
|
||||||
|
@ -57,7 +65,7 @@ func TestCompleter_Complete(t *testing.T) {
|
||||||
{
|
{
|
||||||
line: "cmd -h ",
|
line: "cmd -h ",
|
||||||
point: -1,
|
point: -1,
|
||||||
want: []string{"sub1", "sub2"},
|
want: []string{"sub1", "sub2", "sub3"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
line: "cmd -global1 ", // global1 is known follow flag
|
line: "cmd -global1 ", // global1 is known follow flag
|
||||||
|
@ -67,7 +75,7 @@ func TestCompleter_Complete(t *testing.T) {
|
||||||
{
|
{
|
||||||
line: "cmd sub",
|
line: "cmd sub",
|
||||||
point: -1,
|
point: -1,
|
||||||
want: []string{"sub1", "sub2"},
|
want: []string{"sub1", "sub2", "sub3"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
line: "cmd sub1",
|
line: "cmd sub1",
|
||||||
|
@ -82,7 +90,12 @@ func TestCompleter_Complete(t *testing.T) {
|
||||||
{
|
{
|
||||||
line: "cmd sub1 ",
|
line: "cmd sub1 ",
|
||||||
point: -1,
|
point: -1,
|
||||||
want: []string{},
|
want: []string{"sub11"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
line: "cmd sub3 ",
|
||||||
|
point: -1,
|
||||||
|
want: []string{"sub3"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
line: "cmd sub1 -",
|
line: "cmd sub1 -",
|
||||||
|
@ -142,7 +155,7 @@ func TestCompleter_Complete(t *testing.T) {
|
||||||
{
|
{
|
||||||
line: "cmd -no-such-flag ",
|
line: "cmd -no-such-flag ",
|
||||||
point: -1,
|
point: -1,
|
||||||
want: []string{"sub1", "sub2"},
|
want: []string{"sub1", "sub2", "sub3"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
line: "cmd -no-such-flag -",
|
line: "cmd -no-such-flag -",
|
||||||
|
@ -157,7 +170,7 @@ func TestCompleter_Complete(t *testing.T) {
|
||||||
{
|
{
|
||||||
line: "cmd no-such-command ",
|
line: "cmd no-such-command ",
|
||||||
point: -1,
|
point: -1,
|
||||||
want: []string{"sub1", "sub2"},
|
want: []string{"sub1", "sub2", "sub3"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
line: "cmd -o ",
|
line: "cmd -o ",
|
||||||
|
@ -212,12 +225,12 @@ func TestCompleter_Complete(t *testing.T) {
|
||||||
{
|
{
|
||||||
line: "cmd -o ./readme.md ",
|
line: "cmd -o ./readme.md ",
|
||||||
point: -1,
|
point: -1,
|
||||||
want: []string{"sub1", "sub2"},
|
want: []string{"sub1", "sub2", "sub3"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
line: "cmd -o=./readme.md ",
|
line: "cmd -o=./readme.md ",
|
||||||
point: -1,
|
point: -1,
|
||||||
want: []string{"sub1", "sub2"},
|
want: []string{"sub1", "sub2", "sub3"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
line: "cmd -o sub2 -flag3 ",
|
line: "cmd -o sub2 -flag3 ",
|
||||||
|
@ -256,7 +269,7 @@ func TestCompleter_Complete(t *testing.T) {
|
||||||
line: "cmd -o ",
|
line: "cmd -o ",
|
||||||
// ^
|
// ^
|
||||||
point: 4,
|
point: 4,
|
||||||
want: []string{"sub1", "sub2"},
|
want: []string{"sub1", "sub2", "sub3"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue