summaryrefslogtreecommitdiff
path: root/complete_test.go
diff options
context:
space:
mode:
authorAlex Dadgar <[email protected]>2017-08-24 13:22:31 -0700
committerAlex Dadgar <[email protected]>2017-08-24 17:35:36 -0700
commit97340ccc2198ce94214c480eddf0fb82cb8bb14f (patch)
tree80d102a2b056b01a80c24694c3f49b44ed3531e6 /complete_test.go
parent59e6151c5bb3277462aa4c484af0e6f853df662d (diff)
Default to hiding flags that start with hyphen unless last arg has a hyphen
Diffstat (limited to 'complete_test.go')
-rw-r--r--complete_test.go43
1 files changed, 16 insertions, 27 deletions
diff --git a/complete_test.go b/complete_test.go
index 768f2c8..68efb0f 100644
--- a/complete_test.go
+++ b/complete_test.go
@@ -25,13 +25,6 @@ func TestCompleter_Complete(t *testing.T) {
},
Args: PredictFiles("*.md"),
},
- "sub3": {
- Flags: Flags{
- "-flag4": PredictAnything,
- "-flag5": PredictNothing,
- },
- FlagsRequirePrefix: "-",
- },
},
Flags: Flags{
"-o": PredictFiles("*.txt"),
@@ -48,7 +41,7 @@ func TestCompleter_Complete(t *testing.T) {
}{
{
args: "",
- want: []string{"sub1", "sub2", "sub3", "-h", "-global1", "-o"},
+ want: []string{"sub1", "sub2"},
},
{
args: "-",
@@ -56,7 +49,7 @@ func TestCompleter_Complete(t *testing.T) {
},
{
args: "-h ",
- want: []string{"sub1", "sub2", "sub3", "-h", "-global1", "-o"},
+ want: []string{"sub1", "sub2"},
},
{
args: "-global1 ", // global1 is known follow flag
@@ -64,7 +57,7 @@ func TestCompleter_Complete(t *testing.T) {
},
{
args: "sub",
- want: []string{"sub1", "sub2", "sub3"},
+ want: []string{"sub1", "sub2"},
},
{
args: "sub1",
@@ -75,16 +68,16 @@ func TestCompleter_Complete(t *testing.T) {
want: []string{"sub2"},
},
{
- args: "sub3",
- want: []string{"sub3"},
+ args: "sub1 ",
+ want: []string{},
},
{
- args: "sub1 ",
+ args: "sub1 -",
want: []string{"-flag1", "-flag2", "-h", "-global1"},
},
{
args: "sub2 ",
- want: []string{"./", "dir/", "outer/", "readme.md", "-flag2", "-flag3", "-h", "-global1"},
+ want: []string{"./", "dir/", "outer/", "readme.md"},
},
{
args: "sub2 ./",
@@ -100,7 +93,7 @@ func TestCompleter_Complete(t *testing.T) {
},
{
args: "sub2 -flag2 ",
- want: []string{"./", "dir/", "outer/", "readme.md", "-flag2", "-flag3", "-h", "-global1"},
+ want: []string{"./", "dir/", "outer/", "readme.md"},
},
{
args: "sub1 -fl",
@@ -115,24 +108,20 @@ func TestCompleter_Complete(t *testing.T) {
want: []string{}, // flag1 is unknown follow flag
},
{
- args: "sub1 -flag2 ",
+ args: "sub1 -flag2 -",
want: []string{"-flag1", "-flag2", "-h", "-global1"},
},
{
- args: "sub3 ",
- want: []string{"-h", "-global1"},
- },
- {
- args: "sub3 -",
- want: []string{"-flag4", "-flag5", "-h", "-global1"},
- },
- {
args: "-no-such-flag",
want: []string{},
},
{
args: "-no-such-flag ",
- want: []string{"sub1", "sub2", "sub3", "-h", "-global1", "-o"},
+ want: []string{"sub1", "sub2"},
+ },
+ {
+ args: "-no-such-flag -",
+ want: []string{"-h", "-global1", "-o"},
},
{
args: "no-such-command",
@@ -140,7 +129,7 @@ func TestCompleter_Complete(t *testing.T) {
},
{
args: "no-such-command ",
- want: []string{"sub1", "sub2", "sub3", "-h", "-global1", "-o"},
+ want: []string{"sub1", "sub2"},
},
{
args: "-o ",
@@ -168,7 +157,7 @@ func TestCompleter_Complete(t *testing.T) {
},
{
args: "-o ./readme.md ",
- want: []string{"sub1", "sub2", "sub3", "-h", "-global1", "-o"},
+ want: []string{"sub1", "sub2"},
},
{
args: "-o sub2 -flag3 ",