remove "__complete" command invocation
diff --git a/completion_test.go b/completion_test.go
index cdf476f..7dc916c 100644
--- a/completion_test.go
+++ b/completion_test.go
@@ -218,7 +218,7 @@
p := NewParser(&completionTestOptions, None)
- _, err := p.ParseArgs(append([]string{"__complete", "--"}, test.Args...))
+ _, err := p.ParseArgs(test.Args)
w.Close()
diff --git a/examples/bash-completion b/examples/bash-completion
index 070ae40..974f52a 100644
--- a/examples/bash-completion
+++ b/examples/bash-completion
@@ -2,7 +2,7 @@
args=("${COMP_WORDS[@]:1:$COMP_CWORD}")
local IFS=$'\n'
- COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} __complete -- "${args[@]}"))
+ COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} "${args[@]}"))
return 1
}
diff --git a/flags.go b/flags.go
index 923379b..a425c11 100644
--- a/flags.go
+++ b/flags.go
@@ -196,13 +196,12 @@
and it is up to the user to make sure there are no negative side effects (for
example from init functions).
-Completion works by setting the environment variable
-`GO_FLAGS_COMPLETION=1`, which enables a builtin flags command (named
-`__complete`) which can be used to output a list of completions for the
-passed arguments. The basic invocation to complete a set of arguments is
-therefore:
+Setting the environment variable `GO_FLAGS_COMPLETION=1` enables completion
+by replacing the argument parsing routine with the completion routine which
+outputs completions for the passed arguments. The basic invocation to
+complete a set of arguments is therefore:
- GO_FLAGS_COMPLETION=1 ./completion-example __complete -- arg1 arg2 arg3
+ GO_FLAGS_COMPLETION=1 ./completion-example arg1 arg2 arg3
where `completion-example` is the binary, `arg1` and `arg2` are
the current arguments, and `arg3` (the last argument) is the argument
@@ -220,7 +219,7 @@
# Call completion (note that the first element of COMP_WORDS is
# the executable itself)
- COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} __complete -- "${args[@]}"))
+ COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} "${args[@]}"))
return 0
}