-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate bash completion for hurl/hurlfmt
- Loading branch information
1 parent
39cf735
commit 30062f8
Showing
4 changed files
with
86 additions
and
0 deletions.
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,40 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Generate Completion files | ||
""" | ||
from typing import * | ||
from option import Option | ||
|
||
|
||
def generate_bash_completion(name: str, options: List[Option]): | ||
available_options = ["--" + option.long for option in options] + [ | ||
"--help", | ||
"--version", | ||
] | ||
return ( | ||
"# " | ||
+ name | ||
+ """(1) completion -*- shell-script -*- | ||
_""" | ||
+ name | ||
+ """() | ||
{ | ||
local cur prev words cword | ||
_init_completion || return | ||
if [[ $cur == -* ]]; then | ||
COMPREPLY=($(compgen -W '""" | ||
+ " ".join(available_options) | ||
+ """' -- "$cur")) | ||
return | ||
fi | ||
} && | ||
complete -F _""" | ||
+ name | ||
+ " " | ||
+ name | ||
+ """ | ||
# ex: filetype=sh | ||
""" | ||
) |
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,15 @@ | ||
# hurl(1) completion -*- shell-script -*- | ||
_hurl() | ||
{ | ||
local cur prev words cword | ||
_init_completion || return | ||
|
||
if [[ $cur == -* ]]; then | ||
COMPREPLY=($(compgen -W '--aws-sigv4 --cacert --cert --key --color --compressed --connect-timeout --connect-to --continue-on-error --cookie --cookie-jar --delay --error-format --fail-at-end --file-root --location --location-trusted --glob --http1.0 --http1.1 --http2 --http3 --ignore-asserts --include --insecure --interactive --ipv4 --ipv6 --json --max-redirs --max-time --netrc --netrc-file --netrc-optional --no-color --no-output --noproxy --output --path-as-is --proxy --report-html --report-junit --report-tap --resolve --retry --retry-interval --ssl-no-revoke --test --to-entry --unix-socket --user --user-agent --variable --variables-file --verbose --very-verbose --help --version' -- "$cur")) | ||
return | ||
fi | ||
|
||
} && | ||
complete -F _hurl hurl | ||
# ex: filetype=sh | ||
|
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,15 @@ | ||
# hurlfmt(1) completion -*- shell-script -*- | ||
_hurlfmt() | ||
{ | ||
local cur prev words cword | ||
_init_completion || return | ||
|
||
if [[ $cur == -* ]]; then | ||
COMPREPLY=($(compgen -W '--check --color --format --in-place --in --no-color --output --out --standalone --help --version' -- "$cur")) | ||
return | ||
fi | ||
|
||
} && | ||
complete -F _hurlfmt hurlfmt | ||
# ex: filetype=sh | ||
|