Add bash file completion for hurl/hurlfmt

This commit is contained in:
Fabrice Reix 2025-02-25 13:11:20 +01:00 committed by hurl-bot
parent 152460428d
commit dece792fb3
No known key found for this signature in database
GPG Key ID: 1283A2B4A0DCAF8D
5 changed files with 17 additions and 11 deletions

View File

@ -29,7 +29,8 @@ _"""
+ """' -- "$cur")) + """' -- "$cur"))
return return
fi fi
# Generate filenames by default
COMPREPLY=($(compgen -f "$cur" | sort))
} && } &&
complete -F _""" complete -F _"""
+ name + name

View File

@ -7,7 +7,8 @@ _hurl()
COMPREPLY=($(compgen -W '--aws-sigv4 --cacert --cert --key --color --compressed --connect-timeout --connect-to --continue-on-error --cookie --cookie-jar --curl --delay --error-format --file-root --location --location-trusted --from-entry --glob --header --http1.0 --http1.1 --http2 --http3 --ignore-asserts --include --insecure --interactive --ipv4 --ipv6 --jobs --json --limit-rate --max-filesize --max-redirs --max-time --netrc --netrc-file --netrc-optional --no-color --no-output --noproxy --output --parallel --path-as-is --proxy --repeat --report-html --report-json --report-junit --report-tap --resolve --retry --retry-interval --secret --ssl-no-revoke --test --to-entry --unix-socket --user --user-agent --variable --variables-file --verbose --very-verbose --help --version' -- "$cur")) COMPREPLY=($(compgen -W '--aws-sigv4 --cacert --cert --key --color --compressed --connect-timeout --connect-to --continue-on-error --cookie --cookie-jar --curl --delay --error-format --file-root --location --location-trusted --from-entry --glob --header --http1.0 --http1.1 --http2 --http3 --ignore-asserts --include --insecure --interactive --ipv4 --ipv6 --jobs --json --limit-rate --max-filesize --max-redirs --max-time --netrc --netrc-file --netrc-optional --no-color --no-output --noproxy --output --parallel --path-as-is --proxy --repeat --report-html --report-json --report-junit --report-tap --resolve --retry --retry-interval --secret --ssl-no-revoke --test --to-entry --unix-socket --user --user-agent --variable --variables-file --verbose --very-verbose --help --version' -- "$cur"))
return return
fi fi
# Generate filenames by default
COMPREPLY=($(compgen -f "$cur" | sort))
} && } &&
complete -F _hurl hurl complete -F _hurl hurl
# ex: filetype=sh # ex: filetype=sh

View File

@ -7,7 +7,8 @@ _hurlfmt()
COMPREPLY=($(compgen -W '--check --color --in-place --in --no-color --output --out --standalone --help --version' -- "$cur")) COMPREPLY=($(compgen -W '--check --color --in-place --in --no-color --output --out --standalone --help --version' -- "$cur"))
return return
fi fi
# Generate filenames by default
COMPREPLY=($(compgen -f "$cur" | sort))
} && } &&
complete -F _hurlfmt hurlfmt complete -F _hurlfmt hurlfmt
# ex: filetype=sh # ex: filetype=sh

View File

@ -1,2 +1,3 @@
--verbose --very-verbose --version --verbose --very-verbose --version
--verbose --verbose
tests_ok/completion_bash.out tests_ok/completion_bash.ps1 tests_ok/completion_bash.sh

View File

@ -4,12 +4,14 @@ set -Eeuo pipefail
# shellcheck source=/dev/null # shellcheck source=/dev/null
source ../../completions/hurl.bash source ../../completions/hurl.bash
export COMP_WORDS=(curl --ver) test () {
export COMP_CWORD=1 unset COMPREPLY
_hurl export COMP_WORDS=( hurl "$@" )
echo "${COMPREPLY[*]}" export COMP_CWORD=$(( ${#COMP_WORDS[@]} -1 )) # last parameter
_hurl
echo "${COMPREPLY[*]}"
}
export COMP_WORDS=(curl --verb) test --ver
export COMP_CWORD=1 test --verb
_hurl test --verbose tests_ok/completion_b
echo "${COMPREPLY[*]}"