-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bash and zsh completion scripts for openqa-cli #6063
Open
b10n1k
wants to merge
2
commits into
os-autoinst:master
Choose a base branch
from
b10n1k:autocompletion_cli
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+154
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
_openqa_cli_completions() { | ||
local cur prev subcommands main_options api_options archive_options monitor_options schedule_options | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
subcommands="api archive monitor schedule" | ||
main_options="--apibase --apikey --apisecret --help --host --o3 --osd" | ||
api_options="--json --retries --method --header --links --data-file --data --form --param-file" | ||
archive_options="--asset-size-limit --name --with-thumbnails" | ||
monitor_options="--name --poll-interval" | ||
schedule_options="--monitor --name --poll-interval" | ||
|
||
if [[ ${COMP_CWORD} -eq 1 ]]; then | ||
COMPREPLY=($(compgen -W "$subcommands" -- "$cur")) | ||
return 0 | ||
fi | ||
case "${COMP_WORDS[1]}" in | ||
api) | ||
COMPREPLY=($(compgen -W "$main_options $api_options" -- "$cur")) | ||
;; | ||
archive) | ||
COMPREPLY=($(compgen -W "$main_options $archive_options" -- "$cur")) | ||
;; | ||
monitor) | ||
COMPREPLY=($(compgen -W "$main_options $monitor_options" -- "$cur")) | ||
;; | ||
schedule) | ||
COMPREPLY=($(compgen -W "$main_options $schedule_options" -- "$cur")) | ||
;; | ||
*) | ||
COMPREPLY=($(compgen -W "$subcommands" -- "$cur")) | ||
;; | ||
esac | ||
} | ||
|
||
# Register the completion function for openqa-cli | ||
complete -F _openqa_cli_completions openqa-cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#compdef openqa-cli | ||
|
||
_openqa_cli_completions() { | ||
local curcontext="$curcontext" state line | ||
typeset -A opt_args | ||
local -a subcommands | ||
local -a main_options | ||
local -a output_options | ||
local -a api_options | ||
local -a archive_options | ||
local -a monitor_options | ||
local -a schedule_options | ||
subcommands=("api" "archive" "monitor" "schedule") | ||
main_options=( | ||
'--apibase[Base URL for the API]' | ||
'--apikey[API key for authentication]' | ||
'--apisecret[API secret for authentication]' | ||
'--help[Show help message]' | ||
'--host[Target host, defaults to http://localhost]' | ||
'--o3[Set target host to https://openqa.opensuse.org]' | ||
'--osd[Set target host to http://openqa.suse.de]' | ||
) | ||
output_options=( | ||
'--pretty[Pretty print JSON content]' | ||
'--quiet[Do not print error messages to STDERR]' | ||
'--verbose[Print HTTP response headers]' | ||
) | ||
api_options=( | ||
'--json[Request content is JSON]' | ||
'--retries[Retry up to the specified value on some error]' | ||
'--method[HTTP method to use, defaults to GET]' | ||
'--header[One or more additional HTTP headers]' | ||
'--links[Print pagination links to STDERR]' | ||
'--data-file[Load content to send with request from file]' | ||
'--data[Content to send with request]' | ||
'--form[Turn JSON object into form parameters]' | ||
'--param-file[Load content of params from files instead of from command line arguments.]' | ||
) | ||
archive_options=( | ||
'--asset-size-limit[Asset size limit in bytes]' | ||
'--name[Name of this client, used by openQA to identify different clients via User-Agent header, defaults to "openqa-cli"]' | ||
'--with-thumbnails[Download thumbnails as well]' | ||
) | ||
monitor_options=( | ||
'--name[Name of this client, used by openQA to identify different clients via User-Agent header, defaults to "openqa-cli"]' | ||
'--poll-interval[Specifies the poll interval in seconds]' | ||
) | ||
schedule_options=( | ||
'--monitor[it until all jobs are done/cancelled and return non-zero exit code if at least on job has not passed/softfailed]' | ||
'--name[Name of this client, used by openQA to identify different clients via User-Agent header, defaults to "openqa-cli"]' | ||
'--poll-interval[Specifies the poll interval in seconds]' | ||
) | ||
# Complete with subcommands | ||
if (( CURRENT == 2 )); then | ||
_describe 'subcommand' subcommands | ||
else | ||
case "$words[2]" in | ||
api) | ||
_arguments '*:option:->options' $main_options $api_options | ||
;; | ||
archive) | ||
_arguments '*:option:->options' $main_options $archive_options | ||
;; | ||
monitor) | ||
_arguments '*:option:->options' $main_options $monitor_options | ||
;; | ||
schedule) | ||
_arguments '*:option:->options' $main_options $schedule_options | ||
;; | ||
*) | ||
_values 'subcommand' api archive monitor schedule | ||
;; | ||
esac | ||
fi | ||
} | ||
|
||
# Register the completion function for openqa-cli | ||
compdef _openqa_cli_completions openqa-cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't add anything to a user's bashrc/zshrc by default when doing
make install
.And if they have bash-completion installed, it shouldn't be necessary anyway. Same for zsh.