This takes airlift's 'suggest' command and reuses it as a different command name, 'completion'. This gives us in-built CLI completions which are useful in the repo-level container's docker-entrypoint.sh. This previously parsed Java files for conventional usage of Command annotations, which is potentially buggy. The new implementation relies only on CLI to provide command completion suggestions.
As part of this, we can prepare for bash completion scripts which can be added to our homebrew formula. The new completion command will also complete on command options, for example:
cli completion generate
This will provide all short and long form switches available to the generate command.
Example (commands available globally):
$ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar completion
list
generate
meta
langs
help
config-help
validate
version
completion
Example (switches available to generate
command):
$ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar completion generate
-c
--config
--invoker-package
--git-repo-id
--additional-properties
-t
--template-dir
--import-mappings
-v
--verbose
--model-name-suffix
--library
-s
--skip-overwrite
--artifact-id
--api-package
-D
--ignore-file-override
--model-package
--instantiation-types
--model-name-prefix
--git-user-id
-o
--output
--group-id
-l
--lang
-g
--generator-name
--language-specific-primitives
--artifact-version
--reserved-words-mappings
-a
--auth
-i
--input-spec
--release-note
--remove-operation-id-prefix
--type-mappings
--http-user-agent
Example (switches available to meta
command):
$ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar completion meta
-n
--name
-p
--package
-o
--output
This also moves the exit code of 1 for executing the CLI with no args to after the run
call, allowing CLI to execute the default command before exiting as an error.
/cc @jmini @wing328 (I don't know who is considered technical committee for CLI, maven plugin, etc)
PR checklist
-
Read the contribution guidelines. -
Ran the shell script under ./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
. -
Filed the PR against the correct branch: Default: master
. -
Copied the technical committee to review the pull request if your PR is targeting a particular programming language.