From 5b8d663b633111b1f9e7e8465412db844f7a7741 Mon Sep 17 00:00:00 2001 From: ducaale Date: Mon, 29 Aug 2022 11:59:40 +0100 Subject: [PATCH] document possible values of --pretty in completions --- completions/_xh | 17 ++++++++++------- completions/_xh.ps1 | 12 ++++++------ completions/xh.fish | 10 +++++----- doc/xh.1 | 2 +- src/cli.rs | 4 ++++ 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/completions/_xh b/completions/_xh index 5998c9bc..b8e67028 100644 --- a/completions/_xh +++ b/completions/_xh @@ -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: ' \ @@ -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: ' \ @@ -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[]' \ @@ -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 } diff --git a/completions/_xh.ps1 b/completions/_xh.ps1 index 3b8587a5..125effa7 100644 --- a/completions/_xh.ps1 +++ b/completions/_xh.ps1 @@ -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') @@ -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') @@ -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') diff --git a/completions/xh.fish b/completions/xh.fish index c931b8e7..78c9ec8c 100644 --- a/completions/xh.fish +++ b/completions/xh.fish @@ -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 @@ -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 @@ -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 diff --git a/doc/xh.1 b/doc/xh.1 index 43a88ebd..ed682843 100644 --- a/doc/xh.1 +++ b/doc/xh.1 @@ -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 diff --git a/src/cli.rs b/src/cli.rs index e474d955..6b95877c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -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, }