Skip to content

Commit

Permalink
document possible values of --pretty in completions
Browse files Browse the repository at this point in the history
  • Loading branch information
ducaale committed Aug 29, 2022
1 parent 2d8e4ab commit 5b8d663
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
17 changes: 10 additions & 7 deletions completions/_xh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ _xh() {
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
'--raw=[Pass raw request data without extra processing]:RAW: ' \
'--pretty=[Controls output processing]:STYLE:(all colors format none)' \
'--pretty=[Controls output processing \[possible values: all, colors, format, none\]]:STYLE:((all\:"(default) Enable both coloring and formatting"
colors\:"Apply syntax highlighting to output"
format\:"Pretty-print json and sort headers"
none\:"Disable both coloring and formatting"))' \
'-s+[Output coloring style]:THEME:(auto solarized monokai fruity)' \
'--style=[Output coloring style]:THEME:(auto solarized monokai fruity)' \
'--response-charset=[Override the response encoding for terminal display purposes]:ENCODING: ' \
Expand All @@ -31,12 +34,12 @@ _xh() {
'(--session)--session-read-only=[Create or read a session without updating it form the request/response exchange]:FILE: ' \
'-A+[Specify the auth mechanism]:AUTH_TYPE:(basic bearer digest)' \
'--auth-type=[Specify the auth mechanism]:AUTH_TYPE:(basic bearer digest)' \
'-a+[Authenticate as USER with PASS or with TOKEN]:USER[:PASS] | TOKEN: ' \
'--auth=[Authenticate as USER with PASS or with TOKEN]:USER[:PASS] | TOKEN: ' \
'-a+[Authenticate as USER with PASS (-A basic|digest) or with TOKEN (-A bearer)]:USER[:PASS] | TOKEN: ' \
'--auth=[Authenticate as USER with PASS (-A basic|digest) or with TOKEN (-A bearer)]:USER[:PASS] | TOKEN: ' \
'--bearer=[Authenticate with a bearer token]:TOKEN: ' \
'--max-redirects=[Number of redirects to follow, only respected if `follow` is set]:NUM: ' \
'--max-redirects=[Number of redirects to follow. Only respected if --follow is used]:NUM: ' \
'--timeout=[Connection timeout of the request]:SEC: ' \
'*--proxy=[Use a proxy for a protocol. For example: `--proxy https:http://proxy.host:8080`]:PROTOCOL:URL: ' \
'*--proxy=[Use a proxy for a protocol. For example: --proxy https:http://proxy.host:8080]:PROTOCOL:URL: ' \
'--verify=[If "no", skip SSL verification. If a file path, use it as a CA bundle]:VERIFY: ' \
'--cert=[Use a client side certificate for SSL]:FILE: ' \
'--cert-key=[A private key file to use with --cert]:FILE: ' \
Expand Down Expand Up @@ -76,7 +79,7 @@ _xh() {
'--https[Make HTTPS requests if not specified in the URL]' \
'-I[Do not attempt to read stdin]' \
'--ignore-stdin[Do not attempt to read stdin]' \
'--curl[Print a translation to a `curl` command]' \
'--curl[Print a translation to a curl command]' \
'--curl-long[Use the long versions of curl'\''s flags]' \
'--no-help[]' \
'--no-version[]' \
Expand Down Expand Up @@ -122,7 +125,7 @@ _xh() {
'--no-ignore-stdin[]' \
'--no-curl[]' \
'--no-curl-long[]' \
':raw-method-or-url -- The request URL, preceded by an optional HTTP method:' \
':raw-method-or-url -- The request URL, preceded by an optional HTTP method.:' \
'*::raw-rest-args -- Optional key-value pairs to be included in the request:' \
&& ret=0
}
Expand Down
12 changes: 6 additions & 6 deletions completions/_xh.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Register-ArgumentCompleter -Native -CommandName 'xh' -ScriptBlock {
$completions = @(switch ($command) {
'xh' {
[CompletionResult]::new('--raw', 'raw', [CompletionResultType]::ParameterName, 'Pass raw request data without extra processing')
[CompletionResult]::new('--pretty', 'pretty', [CompletionResultType]::ParameterName, 'Controls output processing')
[CompletionResult]::new('--pretty', 'pretty', [CompletionResultType]::ParameterName, 'Controls output processing [possible values: all, colors, format, none]')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Output coloring style')
[CompletionResult]::new('--style', 'style', [CompletionResultType]::ParameterName, 'Output coloring style')
[CompletionResult]::new('--response-charset', 'response-charset', [CompletionResultType]::ParameterName, 'Override the response encoding for terminal display purposes')
Expand All @@ -37,12 +37,12 @@ Register-ArgumentCompleter -Native -CommandName 'xh' -ScriptBlock {
[CompletionResult]::new('--session-read-only', 'session-read-only', [CompletionResultType]::ParameterName, 'Create or read a session without updating it form the request/response exchange')
[CompletionResult]::new('-A', 'A', [CompletionResultType]::ParameterName, 'Specify the auth mechanism')
[CompletionResult]::new('--auth-type', 'auth-type', [CompletionResultType]::ParameterName, 'Specify the auth mechanism')
[CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Authenticate as USER with PASS or with TOKEN')
[CompletionResult]::new('--auth', 'auth', [CompletionResultType]::ParameterName, 'Authenticate as USER with PASS or with TOKEN')
[CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Authenticate as USER with PASS (-A basic|digest) or with TOKEN (-A bearer)')
[CompletionResult]::new('--auth', 'auth', [CompletionResultType]::ParameterName, 'Authenticate as USER with PASS (-A basic|digest) or with TOKEN (-A bearer)')
[CompletionResult]::new('--bearer', 'bearer', [CompletionResultType]::ParameterName, 'Authenticate with a bearer token')
[CompletionResult]::new('--max-redirects', 'max-redirects', [CompletionResultType]::ParameterName, 'Number of redirects to follow, only respected if `follow` is set')
[CompletionResult]::new('--max-redirects', 'max-redirects', [CompletionResultType]::ParameterName, 'Number of redirects to follow. Only respected if --follow is used')
[CompletionResult]::new('--timeout', 'timeout', [CompletionResultType]::ParameterName, 'Connection timeout of the request')
[CompletionResult]::new('--proxy', 'proxy', [CompletionResultType]::ParameterName, 'Use a proxy for a protocol. For example: `--proxy https:http://proxy.host:8080`')
[CompletionResult]::new('--proxy', 'proxy', [CompletionResultType]::ParameterName, 'Use a proxy for a protocol. For example: --proxy https:http://proxy.host:8080')
[CompletionResult]::new('--verify', 'verify', [CompletionResultType]::ParameterName, 'If "no", skip SSL verification. If a file path, use it as a CA bundle')
[CompletionResult]::new('--cert', 'cert', [CompletionResultType]::ParameterName, 'Use a client side certificate for SSL')
[CompletionResult]::new('--cert-key', 'cert-key', [CompletionResultType]::ParameterName, 'A private key file to use with --cert')
Expand Down Expand Up @@ -82,7 +82,7 @@ Register-ArgumentCompleter -Native -CommandName 'xh' -ScriptBlock {
[CompletionResult]::new('--https', 'https', [CompletionResultType]::ParameterName, 'Make HTTPS requests if not specified in the URL')
[CompletionResult]::new('-I', 'I', [CompletionResultType]::ParameterName, 'Do not attempt to read stdin')
[CompletionResult]::new('--ignore-stdin', 'ignore-stdin', [CompletionResultType]::ParameterName, 'Do not attempt to read stdin')
[CompletionResult]::new('--curl', 'curl', [CompletionResultType]::ParameterName, 'Print a translation to a `curl` command')
[CompletionResult]::new('--curl', 'curl', [CompletionResultType]::ParameterName, 'Print a translation to a curl command')
[CompletionResult]::new('--curl-long', 'curl-long', [CompletionResultType]::ParameterName, 'Use the long versions of curl''s flags')
[CompletionResult]::new('--no-help', 'no-help', [CompletionResultType]::ParameterName, 'no-help')
[CompletionResult]::new('--no-version', 'no-version', [CompletionResultType]::ParameterName, 'no-version')
Expand Down
10 changes: 5 additions & 5 deletions completions/xh.fish
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
complete -c xh -l raw -d 'Pass raw request data without extra processing' -r
complete -c xh -l pretty -d 'Controls output processing' -r -f -a "{all ,colors ,format ,none }"
complete -c xh -l pretty -d 'Controls output processing [possible values: all, colors, format, none]' -r -f -a "{all (default) Enable both coloring and formatting,colors Apply syntax highlighting to output,format Pretty-print json and sort headers,none Disable both coloring and formatting}"
complete -c xh -s s -l style -d 'Output coloring style' -r -f -a "{auto ,solarized ,monokai ,fruity }"
complete -c xh -l response-charset -d 'Override the response encoding for terminal display purposes' -r
complete -c xh -l response-mime -d 'Override the response mime type for coloring and formatting for the terminal' -r
Expand All @@ -9,11 +9,11 @@ complete -c xh -s o -l output -d 'Save output to FILE instead of stdout' -r
complete -c xh -l session -d 'Create, or reuse and update a session' -r
complete -c xh -l session-read-only -d 'Create or read a session without updating it form the request/response exchange' -r
complete -c xh -s A -l auth-type -d 'Specify the auth mechanism' -r -f -a "{basic ,bearer ,digest }"
complete -c xh -s a -l auth -d 'Authenticate as USER with PASS or with TOKEN' -r
complete -c xh -s a -l auth -d 'Authenticate as USER with PASS (-A basic|digest) or with TOKEN (-A bearer)' -r
complete -c xh -l bearer -d 'Authenticate with a bearer token' -r
complete -c xh -l max-redirects -d 'Number of redirects to follow, only respected if `follow` is set' -r
complete -c xh -l max-redirects -d 'Number of redirects to follow. Only respected if --follow is used' -r
complete -c xh -l timeout -d 'Connection timeout of the request' -r
complete -c xh -l proxy -d 'Use a proxy for a protocol. For example: `--proxy https:http://proxy.host:8080`' -r
complete -c xh -l proxy -d 'Use a proxy for a protocol. For example: --proxy https:http://proxy.host:8080' -r
complete -c xh -l verify -d 'If "no", skip SSL verification. If a file path, use it as a CA bundle' -r
complete -c xh -l cert -d 'Use a client side certificate for SSL' -r
complete -c xh -l cert-key -d 'A private key file to use with --cert' -r
Expand All @@ -40,7 +40,7 @@ complete -c xh -s F -l follow -d 'Do follow redirects'
complete -c xh -l native-tls -d 'Use the system TLS library instead of rustls (if enabled at compile time)'
complete -c xh -l https -d 'Make HTTPS requests if not specified in the URL'
complete -c xh -s I -l ignore-stdin -d 'Do not attempt to read stdin'
complete -c xh -l curl -d 'Print a translation to a `curl` command'
complete -c xh -l curl -d 'Print a translation to a curl command'
complete -c xh -l curl-long -d 'Use the long versions of curl\'s flags'
complete -c xh -l no-help
complete -c xh -l no-version
Expand Down
2 changes: 1 addition & 1 deletion doc/xh.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH XH 1 2022-08-21 0.16.1 "User Commands"
.TH XH 1 2022-08-29 0.16.1 "User Commands"

.SH NAME
xh \- Friendly and fast tool for sending HTTP requests
Expand Down
4 changes: 4 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -913,9 +913,13 @@ impl Default for AuthType {

#[derive(ArgEnum, Debug, PartialEq, Eq, Clone, Copy)]
pub enum Pretty {
/// (default) Enable both coloring and formatting
All,
/// Apply syntax highlighting to output
Colors,
/// Pretty-print json and sort headers
Format,
/// Disable both coloring and formatting
None,
}

Expand Down

0 comments on commit 5b8d663

Please sign in to comment.