Remove plural handling and add aliases for nouns in completion

This commit is contained in:
Dr. Stefan Schimanski
2016-03-25 16:05:56 +01:00
parent c678ff029e
commit 1a0a490d76
4 changed files with 64 additions and 8 deletions

View File

@ -43,9 +43,13 @@ func TestBashCompletions(t *testing.T) {
c.MarkFlagRequired("introot")
// valid nouns
validArgs := []string{"pods", "nodes", "services", "replicationControllers"}
validArgs := []string{"pod", "node", "service", "replicationcontroller"}
c.ValidArgs = validArgs
// noun aliases
argAliases := []string{"pods", "nodes", "services", "replicationcontrollers", "po", "no", "svc", "rc"}
c.ArgAliases = argAliases
// filename
var flagval string
c.Flags().StringVar(&flagval, "filename", "", "Enter a filename")
@ -88,7 +92,11 @@ func TestBashCompletions(t *testing.T) {
// check for custom completion function
check(t, str, `COMPREPLY=( "hello" )`)
// check for required nouns
check(t, str, `must_have_one_noun+=("pods")`)
check(t, str, `must_have_one_noun+=("pod")`)
// check for noun aliases
check(t, str, `noun_aliases+=("pods")`)
check(t, str, `noun_aliases+=("rc")`)
checkOmit(t, str, `must_have_one_noun+=("pods")`)
// check for filename extension flags
check(t, str, `flags_completion+=("_filedir")`)
// check for filename extension flags