Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !213

[cli] Completions command for suggestions

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Jim Schubert requested to merge github/fork/jimschubert/cli-commands-command into master Jun 03, 2018
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 3

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.
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/jimschubert/cli-commands-command