summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplustik <plustik@tecks.eu>2023-11-18 21:17:57 +0100
committerplustik <plustik@tecks.eu>2023-11-18 21:17:57 +0100
commite5167365b5c04e322b5ea2a6ba48180ce7fcbb2a (patch)
treee2e42ef060c553086e560cf7c269adc1607a81c9
parent888410815f71d26c7ae548ec247fbbea9b78c3c0 (diff)
Improve completion for some args
-rw-r--r--etc/completion/completion.bash12
-rw-r--r--etc/completion/completion.fish14
-rw-r--r--etc/completion/completion.zsh14
-rw-r--r--src/cli.rs19
4 files changed, 31 insertions, 28 deletions
diff --git a/etc/completion/completion.bash b/etc/completion/completion.bash
index b55866cc..5c7de994 100644
--- a/etc/completion/completion.bash
+++ b/etc/completion/completion.bash
@@ -138,7 +138,7 @@ _delta() {
return 0
;;
--grep-output-type)
- COMPREPLY=($(compgen -f "${cur}"))
+ COMPREPLY=($(compgen -W "ripgrep classic" -- "${cur}"))
return 0
;;
--grep-match-line-style)
@@ -186,7 +186,7 @@ _delta() {
return 0
;;
--inspect-raw-lines)
- COMPREPLY=($(compgen -f "${cur}"))
+ COMPREPLY=($(compgen -W "true false" -- "${cur}"))
return 0
;;
--line-buffer-size)
@@ -194,7 +194,7 @@ _delta() {
return 0
;;
--line-fill-method)
- COMPREPLY=($(compgen -f "${cur}"))
+ COMPREPLY=($(compgen -W "ansi spaces" -- "${cur}"))
return 0
;;
--line-numbers-left-format)
@@ -286,7 +286,7 @@ _delta() {
return 0
;;
--paging)
- COMPREPLY=($(compgen -f "${cur}"))
+ COMPREPLY=($(compgen -W "auto always never" -- "${cur}"))
return 0
;;
--plus-emph-style)
@@ -318,7 +318,7 @@ _delta() {
return 0
;;
--true-color)
- COMPREPLY=($(compgen -f "${cur}"))
+ COMPREPLY=($(compgen -W "auto always never" -- "${cur}"))
return 0
;;
--whitespace-error-style)
@@ -362,7 +362,7 @@ _delta() {
return 0
;;
--24-bit-color)
- COMPREPLY=($(compgen -f "${cur}"))
+ COMPREPLY=($(compgen -W "auto always never" -- "${cur}"))
return 0
;;
*)
diff --git a/etc/completion/completion.fish b/etc/completion/completion.fish
index 1b44bf3e..760f54b2 100644
--- a/etc/completion/completion.fish
+++ b/etc/completion/completion.fish
@@ -5,7 +5,7 @@ complete -c delta -l blame-separator-format -d 'Separator between the blame form
complete -c delta -l blame-separator-style -d 'Style string for the blame-separator-format' -r
complete -c delta -l blame-timestamp-format -d 'Format of `git blame` timestamp in raw git output received by delta' -r
complete -c delta -l blame-timestamp-output-format -d 'Format string for git blame timestamp output' -r
-complete -c delta -l config -d 'Load the config file at PATH instead of ~/.gitconfig' -r
+complete -c delta -l config -d 'Load the config file at PATH instead of ~/.gitconfig' -r -F
complete -c delta -l commit-decoration-style -d 'Style string for the commit hash decoration' -r
complete -c delta -l commit-regex -d 'Regular expression used to identify the commit line when parsing git output' -r
complete -c delta -l commit-style -d 'Style string for the commit hash line' -r
@@ -26,7 +26,7 @@ complete -c delta -l grep-file-style -d 'Style string for file paths in grep out
complete -c delta -l grep-header-decoration-style -d 'Style string for the header decoration in grep output' -r
complete -c delta -l grep-header-file-style -d 'Style string for the file path part of the header in grep output' -r
complete -c delta -l grep-line-number-style -d 'Style string for line numbers in grep output' -r
-complete -c delta -l grep-output-type -d 'Grep output format. Possible values: "ripgrep" - file name printed once, followed by matching lines within that file, each preceded by a line number. "classic" - file name:line number, followed by matching line. Default is "ripgrep" if `rg --json` format is detected, otherwise "classic"' -r
+complete -c delta -l grep-output-type -d 'Grep output format. Possible values: "ripgrep" - file name printed once, followed by matching lines within that file, each preceded by a line number. "classic" - file name:line number, followed by matching line. Default is "ripgrep" if `rg --json` format is detected, otherwise "classic"' -r -f -a "{ripgrep '',classic ''}"
complete -c delta -l grep-match-line-style -d 'Style string for matching lines of grep output' -r
complete -c delta -l grep-match-word-style -d 'Style string for the matching substrings within a matching line of grep output' -r
complete -c delta -l grep-separator-symbol -d 'Separator symbol printed after the file path and line number in grep output' -r
@@ -38,9 +38,9 @@ complete -c delta -l hunk-label -d 'Text to display before a hunk header' -r
complete -c delta -l hyperlinks-commit-link-format -d 'Format string for commit hyperlinks (requires --hyperlinks)' -r
complete -c delta -l hyperlinks-file-link-format -d 'Format string for file hyperlinks (requires --hyperlinks)' -r
complete -c delta -l inline-hint-style -d 'Style string for short inline hint text' -r
-complete -c delta -l inspect-raw-lines -d 'Kill-switch for --color-moved support' -r
+complete -c delta -l inspect-raw-lines -d 'Kill-switch for --color-moved support' -r -f -a "{true '',false ''}"
complete -c delta -l line-buffer-size -d 'Size of internal line buffer' -r
-complete -c delta -l line-fill-method -d 'Line-fill method in side-by-side mode' -r
+complete -c delta -l line-fill-method -d 'Line-fill method in side-by-side mode' -r -f -a "{ansi spaces ''}"
complete -c delta -l line-numbers-left-format -d 'Format string for the left column of line numbers' -r
complete -c delta -l line-numbers-left-style -d 'Style string for the left column of line numbers' -r
complete -c delta -l line-numbers-minus-style -d 'Style string for line numbers in the old (minus) version of the file' -r
@@ -63,7 +63,7 @@ complete -c delta -l minus-non-emph-style -d 'Style string for non-emphasized se
complete -c delta -l minus-style -d 'Style string for removed lines' -r
complete -c delta -l navigate-regex -d 'Regular expression defining navigation stop points' -r
complete -c delta -l pager -d 'Which pager to use' -r
-complete -c delta -l paging -d 'Whether to use a pager when displaying output' -r
+complete -c delta -l paging -d 'Whether to use a pager when displaying output' -r -f -a "{auto '',always '',never ''}"
complete -c delta -l plus-emph-style -d 'Style string for emphasized sections of added lines' -r
complete -c delta -l plus-empty-line-marker-style -d 'Style string for added empty line marker' -r
complete -c delta -l plus-non-emph-style -d 'Style string for non-emphasized sections of added lines that have an emphasized section' -r
@@ -71,7 +71,7 @@ complete -c delta -l plus-style -d 'Style string for added lines' -r
complete -c delta -l right-arrow -d 'Text to display with a changed file path' -r
complete -c delta -l syntax-theme -d 'The syntax-highlighting theme to use' -r
complete -c delta -l tabs -d 'The number of spaces to replace tab characters with' -r
-complete -c delta -l true-color -d 'Whether to emit 24-bit ("true color") RGB color codes' -r
+complete -c delta -l true-color -d 'Whether to emit 24-bit ("true color") RGB color codes' -r -f -a "{auto '',always '',never ''}"
complete -c delta -l whitespace-error-style -d 'Style string for whitespace errors' -r
complete -c delta -s w -l width -d 'The width of underline/overline decorations' -r
complete -c delta -l word-diff-regex -d 'Regular expression defining a \'word\' in within-line diff algorithm' -r
@@ -81,7 +81,7 @@ complete -c delta -l wrap-right-percent -d 'Threshold for right-aligning wrapped
complete -c delta -l wrap-right-prefix-symbol -d 'Pre-wrapped content symbol (right-aligned)' -r
complete -c delta -l wrap-right-symbol -d 'End-of-line wrapped content symbol (right-aligned)' -r
complete -c delta -l zero-style -d 'Style string for unchanged lines' -r
-complete -c delta -l 24-bit-color -d 'Deprecated: use --true-color' -r
+complete -c delta -l 24-bit-color -d 'Deprecated: use --true-color' -r -f -a "{auto '',always '',never ''}"
complete -c delta -l color-only -d 'Do not alter the input structurally in any way'
complete -c delta -l dark -d 'Use default colors appropriate for a dark terminal background'
complete -c delta -l diff-highlight -d 'Emulate diff-highlight'
diff --git a/etc/completion/completion.zsh b/etc/completion/completion.zsh
index 4858c317..a62077ed 100644
--- a/etc/completion/completion.zsh
+++ b/etc/completion/completion.zsh
@@ -22,7 +22,7 @@ _delta() {
'--blame-separator-style=[Style string for the blame-separator-format]:STYLE: ' \
'--blame-timestamp-format=[Format of \`git blame\` timestamp in raw git output received by delta]:FMT: ' \
'--blame-timestamp-output-format=[Format string for git blame timestamp output]:FMT: ' \
-'--config=[Load the config file at PATH instead of ~/.gitconfig]:PATH: ' \
+'--config=[Load the config file at PATH instead of ~/.gitconfig]:PATH:_files' \
'--commit-decoration-style=[Style string for the commit hash decoration]:STYLE: ' \
'--commit-regex=[Regular expression used to identify the commit line when parsing git output]:REGEX: ' \
'--commit-style=[Style string for the commit hash line]:STYLE: ' \
@@ -43,7 +43,7 @@ _delta() {
'--grep-header-decoration-style=[Style string for the header decoration in grep output]:STYLE: ' \
'--grep-header-file-style=[Style string for the file path part of the header in grep output]:STYLE: ' \
'--grep-line-number-style=[Style string for line numbers in grep output]:STYLE: ' \
-'--grep-output-type=[Grep output format. Possible values\: "ripgrep" - file name printed once, followed by matching lines within that file, each preceded by a line number. "classic" - file name\:line number, followed by matching line. Default is "ripgrep" if \`rg --json\` format is detected, otherwise "classic"]:OUTPUT_TYPE: ' \
+'--grep-output-type=[Grep output format. Possible values\: "ripgrep" - file name printed once, followed by matching lines within that file, each preceded by a line number. "classic" - file name\:line number, followed by matching line. Default is "ripgrep" if \`rg --json\` format is detected, otherwise "classic"]:OUTPUT_TYPE:(ripgrep classic)' \
'--grep-match-line-style=[Style string for matching lines of grep output]:STYLE: ' \
'--grep-match-word-style=[Style string for the matching substrings within a matching line of grep output]:STYLE: ' \
'--grep-separator-symbol=[Separator symbol printed after the file path and line number in grep output]:STRING: ' \
@@ -55,9 +55,9 @@ _delta() {
'--hyperlinks-commit-link-format=[Format string for commit hyperlinks (requires --hyperlinks)]:FMT: ' \
'--hyperlinks-file-link-format=[Format string for file hyperlinks (requires --hyperlinks)]:FMT: ' \
'--inline-hint-style=[Style string for short inline hint text]:STYLE: ' \
-'--inspect-raw-lines=[Kill-switch for --color-moved support]:true|false: ' \
+'--inspect-raw-lines=[Kill-switch for --color-moved support]:true|false:(true false)' \
'--line-buffer-size=[Size of internal line buffer]:N: ' \
-'--line-fill-method=[Line-fill method in side-by-side mode]:STRING: ' \
+'--line-fill-method=[Line-fill method in side-by-side mode]:STRING:(ansi spaces)' \
'--line-numbers-left-format=[Format string for the left column of line numbers]:FMT: ' \
'--line-numbers-left-style=[Style string for the left column of line numbers]:STYLE: ' \
'--line-numbers-minus-style=[Style string for line numbers in the old (minus) version of the file]:STYLE: ' \
@@ -80,7 +80,7 @@ _delta() {
'--minus-style=[Style string for removed lines]:STYLE: ' \
'--navigate-regex=[Regular expression defining navigation stop points]:REGEX: ' \
'--pager=[Which pager to use]:CMD: ' \
-'--paging=[Whether to use a pager when displaying output]:auto|always|never: ' \
+'--paging=[Whether to use a pager when displaying output]:auto|always|never:(auto always never)' \
'--plus-emph-style=[Style string for emphasized sections of added lines]:STYLE: ' \
'--plus-empty-line-marker-style=[Style string for added empty line marker]:STYLE: ' \
'--plus-non-emph-style=[Style string for non-emphasized sections of added lines that have an emphasized section]:STYLE: ' \
@@ -88,7 +88,7 @@ _delta() {
'--right-arrow=[Text to display with a changed file path]:STRING: ' \
'--syntax-theme=[The syntax-highlighting theme to use]:SYNTAX_THEME: ' \
'--tabs=[The number of spaces to replace tab characters with]:N: ' \
-'--true-color=[Whether to emit 24-bit ("true color") RGB color codes]:auto|always|never: ' \
+'--true-color=[Whether to emit 24-bit ("true color") RGB color codes]:auto|always|never:(auto always never)' \
'--whitespace-error-style=[Style string for whitespace errors]:STYLE: ' \
'-w+[The width of underline/overline decorations]:N: ' \
'--width=[The width of underline/overline decorations]:N: ' \
@@ -99,7 +99,7 @@ _delta() {
'--wrap-right-prefix-symbol=[Pre-wrapped content symbol (right-aligned)]:STRING: ' \
'--wrap-right-symbol=[End-of-line wrapped content symbol (right-aligned)]:STRING: ' \
'--zero-style=[Style string for unchanged lines]:STYLE: ' \
-'--24-bit-color=[Deprecated\: use --true-color]:auto|always|never: ' \
+'--24-bit-color=[Deprecated\: use --true-color]:auto|always|never:(auto always never)' \
'--color-only[Do not alter the input structurally in any way]' \
'--dark[Use default colors appropriate for a dark terminal background]' \
'--diff-highlight[Emulate diff-highlight]' \
diff --git a/src/cli.rs b/src/cli.rs
index 58d8ebef..3617e8d0 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -3,7 +3,7 @@ use std::ffi::OsString;
use std::path::{Path, PathBuf};
use bat::assets::HighlightingAssets;
-use clap::{ColorChoice, CommandFactory, FromArgMatches, Parser};
+use clap::{ColorChoice, CommandFactory, FromArgMatches, Parser, ValueHint};
use clap_complete::Shell;
use lazy_static::lazy_static;
use syntect::highlighting::Theme as SyntaxTheme;
@@ -251,7 +251,7 @@ pub struct Opt {
/// intended for other tools that use delta.
pub color_only: bool,
- #[arg(long = "config", default_value = "", value_name = "PATH")]
+ #[arg(long = "config", default_value = "", value_name = "PATH", value_hint = ValueHint::FilePath)]
/// Load the config file at PATH instead of ~/.gitconfig.
pub config: String,
@@ -434,7 +434,7 @@ pub struct Opt {
/// See STYLES section.
pub grep_line_number_style: String,
- #[arg(long = "grep-output-type", value_name = "OUTPUT_TYPE")]
+ #[arg(long = "grep-output-type", value_name = "OUTPUT_TYPE", value_parser = ["ripgrep", "classic"])]
/// Grep output format. Possible values:
/// "ripgrep" - file name printed once, followed by matching lines within that file, each preceded by a line number.
/// "classic" - file name:line number, followed by matching line.
@@ -568,7 +568,8 @@ pub struct Opt {
#[arg(
long = "inspect-raw-lines",
default_value = "true",
- value_name = "true|false"
+ value_name = "true|false",
+ value_parser = ["true", "false"],
)]
/// Kill-switch for --color-moved support.
///
@@ -600,7 +601,7 @@ pub struct Opt {
/// affect delta's performance when entire files are added/removed.
pub line_buffer_size: usize,
- #[arg(long = "line-fill-method", value_name = "STRING")]
+ #[arg(long = "line-fill-method", value_name = "STRING", value_parser = ["ansi spaces"])]
/// Line-fill method in side-by-side mode.
///
/// How to extend the background color to the end of the line in side-by-side mode. Can be ansi
@@ -851,7 +852,8 @@ pub struct Opt {
#[arg(
long = "paging",
default_value = "auto",
- value_name = "auto|always|never"
+ value_name = "auto|always|never",
+ value_parser = ["auto", "always", "never"],
)]
/// Whether to use a pager when displaying output.
///
@@ -980,7 +982,8 @@ pub struct Opt {
#[arg(
long = "true-color",
default_value = "auto",
- value_name = "auto|always|never"
+ value_name = "auto|always|never",
+ value_parser = ["auto", "always", "never"],
)]
/// Whether to emit 24-bit ("true color") RGB color codes.
///
@@ -1071,7 +1074,7 @@ pub struct Opt {
/// See STYLES section.
pub zero_style: String,
- #[arg(long = "24-bit-color", value_name = "auto|always|never")]
+ #[arg(long = "24-bit-color", value_name = "auto|always|never", value_parser = ["auto", "always", "never"])]
/// Deprecated: use --true-color.
pub _24_bit_color: Option<String>,