From a3eb1d5d1f919ce3809aff8c9d19d461092e09de Mon Sep 17 00:00:00 2001 From: sigoden Date: Thu, 20 Jul 2023 16:23:30 +0800 Subject: [PATCH] refactor: compgen color --- src/compgen.rs | 388 ++++++++++++------ src/matcher.rs | 36 +- tests/compgen.rs | 40 +- .../integration__compgen__arg_terminated.snap | 30 +- ...gration__compgen__assing_option_value.snap | 36 +- .../integration__compgen__choice.snap | Bin 1147 -> 1176 bytes ...tegration__compgen__choice_check_vars.snap | 28 +- .../integration__compgen__choice_multi.snap | 12 +- .../integration__compgen__choice_slash.snap | 2 +- .../integration__compgen__color.snap | 266 ++++++++---- ...egration__compgen__fallback_comp_file.snap | 12 +- .../integration__compgen__just_match.snap | 4 +- ...tion__compgen__last_arg_option_assign.snap | 10 +- .../integration__compgen__multiline_doc.snap | 6 +- .../integration__compgen__multiple.snap | 52 +-- .../integration__compgen__nested_subcmds.snap | 26 +- ...integration__compgen__no_comp_subcmds.snap | 8 +- ...ntegration__compgen__no_flags_options.snap | 4 +- ...tegration__compgen__no_flags_options2.snap | 4 +- .../integration__compgen__no_param.snap | 2 +- ...egration__compgen__one_combine_shorts.snap | 4 +- ...ion__compgen__one_subcmd_with_options.snap | 2 +- ...tegration__compgen__option_multi_vals.snap | 6 +- ...tegration__compgen__option_terminated.snap | 18 +- .../integration__compgen__positionals.snap | 32 +- .../integration__compgen__shorts.snap | 56 +-- ...ntegration__compgen__special_arg_name.snap | 4 +- .../integration__compgen__subcmds.snap | 24 +- 28 files changed, 680 insertions(+), 432 deletions(-) diff --git a/src/compgen.rs b/src/compgen.rs index 9e51b427..5b8eef85 100644 --- a/src/compgen.rs +++ b/src/compgen.rs @@ -8,6 +8,7 @@ use dirs::home_dir; use indexmap::IndexMap; use std::collections::{HashMap, HashSet}; use std::env; +use std::fmt; use std::fs; use std::path::PathBuf; use std::str::FromStr; @@ -49,7 +50,7 @@ pub fn compgen( let compgen_values = matcher.compgen(shell); let mut default_nospace = unbalance.is_some(); let mut prefix = unbalance.map(|v| v.to_string()).unwrap_or_default(); - let mut candidates: IndexMap = IndexMap::new(); + let mut candidates: IndexMap = IndexMap::new(); let mut argc_fn = None; let mut argc_value = None; let mut argc_variables = vec![]; @@ -61,7 +62,7 @@ pub fn compgen( mod_quote(&mut last, &mut prefix, &mut default_nospace); } } - for (value, description, comp_kind) in compgen_values { + for (value, description, comp_color) in compgen_values { if value.starts_with("__argc_") { if let Some(fn_name) = value.strip_prefix("__argc_fn=") { argc_fn = Some(fn_name.to_string()); @@ -83,7 +84,7 @@ pub fn compgen( } } } else if value.starts_with(&last) && !multi_values.contains(&value) { - candidates.insert(value.clone(), (description, default_nospace, comp_kind)); + candidates.insert(value.clone(), (description, default_nospace, comp_color)); } } let mut argc_prefix = prefix.to_string(); @@ -167,9 +168,9 @@ pub fn compgen( } if !argc_variables.is_empty() { - let mut prepend_candicates: IndexMap = argc_variables + let mut prepend_candicates: IndexMap = argc_variables .into_iter() - .map(|value| (value, (String::new(), false, CompKind::Value))) + .map(|value| (value, (String::new(), false, CompColor::of_value()))) .collect(); prepend_candicates.extend(candidates); candidates = prepend_candicates; @@ -177,7 +178,9 @@ pub fn compgen( let mut candidates: Vec = candidates .into_iter() - .map(|(value, (description, nospace, comp_kind))| (value, description, nospace, comp_kind)) + .map(|(value, (description, nospace, comp_color))| { + (value, description, nospace, comp_color) + }) .collect(); if !shell.is_generic() { @@ -228,62 +231,6 @@ pub fn compgen( Ok(values.join("\n")) } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub(crate) enum CompKind { - Flag, - Option, - Command, - Dir, - File, - FileExe, - Symlink, - ValueOther, - ValueAnother, - ValueEmphasis, - ValueSubtle, - Value, -} - -impl FromStr for CompKind { - type Err = anyhow::Error; - - fn from_str(s: &str) -> std::result::Result { - match s.to_ascii_lowercase().as_str() { - "flag" => Ok(Self::Flag), - "option" => Ok(Self::Option), - "command" => Ok(Self::Command), - "dir" => Ok(Self::Dir), - "file" => Ok(Self::File), - "fileexe" => Ok(Self::FileExe), - "symlink" => Ok(Self::Symlink), - "valueother" => Ok(Self::ValueOther), - "valueanother" => Ok(Self::ValueAnother), - "valueemphasis" => Ok(Self::ValueEmphasis), - "valuesubtle" => Ok(Self::ValueSubtle), - _ => Ok(Self::Value), - } - } -} - -impl CompKind { - pub(crate) fn name(&self) -> &str { - match self { - Self::Flag => "flag", - Self::Option => "option", - Self::Command => "command", - Self::Dir => "dir", - Self::File => "file", - Self::FileExe => "exe", - Self::Symlink => "symlink", - Self::ValueOther => "valueOther", - Self::ValueAnother => "valueAnother", - Self::ValueEmphasis => "valueEmphasis", - Self::ValueSubtle => "valueSubtle", - Self::Value => "value", - } - } -} - #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Shell { Bash, @@ -317,7 +264,7 @@ impl FromStr for Shell { } } -pub(crate) type CandidateValue = (String, String, bool, CompKind); // value, description, nospace +pub(crate) type CandidateValue = (String, String, bool, CompColor); // value, description, nospace, comp_color impl Shell { pub fn list() -> [Shell; 7] { @@ -392,7 +339,7 @@ impl Shell { candidates .into_iter() .enumerate() - .map(|(i, (value, description, nospace, _comp_kind))| { + .map(|(i, (value, description, nospace, _comp_color))| { let mut new_value = value; if i == 0 && add_space_to_first_candidate { new_value = format!(" {}", new_value) @@ -409,18 +356,18 @@ impl Shell { } Shell::Elvish | Shell::Powershell => candidates .into_iter() - .map(|(value, description, nospace, comp_kind)| { + .map(|(value, description, nospace, comp_color)| { let new_value = self.combine_value(prefix, &value); let display = if value.is_empty() { " ".into() } else { value }; let description = self.comp_description(&description, "", ""); let space: &str = if nospace { "0" } else { "1" }; - let color = self.color(comp_kind, no_color); + let color = self.color(comp_color, no_color); format!("{new_value}\t{space}\t{display}\t{description}\t{color}") }) .collect::>(), Shell::Fish => candidates .into_iter() - .map(|(value, description, _nospace, _comp_kind)| { + .map(|(value, description, _nospace, _comp_color)| { let new_value = self.combine_value(prefix, &value); let description = self.comp_description(&description, "\t", ""); format!("{new_value}{description}") @@ -428,11 +375,11 @@ impl Shell { .collect::>(), Shell::Generic => candidates .into_iter() - .map(|(value, description, nospace, comp_kind)| { - let comp_kind = format!("\t/kind:{}", comp_kind.name()); + .map(|(value, description, nospace, comp_color)| { + let comp_color = format!("\t/color:{}", comp_color.ser()); let description = self.comp_description(&description, "\t", ""); let space: &str = if nospace { "\0" } else { "" }; - format!("{value}{space}{comp_kind}{description}") + format!("{value}{space}{comp_color}{description}") }) .collect::>(), Shell::Nushell => candidates @@ -471,7 +418,7 @@ impl Shell { .collect::>(), Shell::Zsh => candidates .into_iter() - .map(|(value, description, nospace, comp_kind)| { + .map(|(value, description, nospace, comp_color)| { let prefix = if let Some((_, i)) = unbalance_quote(prefix) { prefix .char_indices() @@ -486,7 +433,7 @@ impl Shell { escape_chars(&value, self.need_escape_chars(), "\\").replace("\\:", ":"); let display = value.replace(':', "\\:"); let description = self.comp_description(&description, ":", ""); - let color = self.color(comp_kind, no_color); + let color = self.color(comp_color, no_color); let space = if nospace { "" } else { " " }; format!("{new_value}{space}\t{display}{description}\t{match_value}\t{color}") }) @@ -522,47 +469,21 @@ impl Shell { } } - pub(crate) fn color(&self, comp_kind: CompKind, no_color: bool) -> &'static str { + pub(crate) fn color(&self, comp_color: CompColor, no_color: bool) -> String { match self { Shell::Elvish => { if no_color { - return "default"; - } - match comp_kind { - CompKind::Flag => "cyan", - CompKind::Option => "cyan bold", - CompKind::Command => "magenta", - CompKind::Dir => "blue bold", - CompKind::File => "default", - CompKind::FileExe => "green bold", - CompKind::Symlink => "cyan bold", - CompKind::ValueOther => "yellow", - CompKind::ValueAnother => "red", - CompKind::ValueEmphasis => "green bold", - CompKind::ValueSubtle => "green dim", - CompKind::Value => "green", + return "default".into(); } + comp_color.style() } Shell::Powershell | Shell::Zsh => { if no_color { - return "39"; - } - match comp_kind { - CompKind::Flag => "36", - CompKind::Option => "1;36", - CompKind::Command => "35", - CompKind::Dir => "1;34", - CompKind::File => "39", - CompKind::FileExe => "1;32", - CompKind::Symlink => "1;36", - CompKind::ValueOther => "33", - CompKind::ValueAnother => "31", - CompKind::ValueEmphasis => "1;32", - CompKind::ValueSubtle => "2;32", - CompKind::Value => "32", + return "39".into(); } + comp_color.ansi_code() } - _ => "", + _ => String::new(), } } @@ -642,7 +563,12 @@ impl Shell { return Some(( "".into(), "".into(), - vec![(format!("{prefix}{filter}"), "".into(), true, CompKind::Dir)], + vec![( + format!("{prefix}{filter}"), + "".into(), + true, + CompColor::of_dir(), + )], )); } let value_prefix = if prefix.is_empty() { ".\\" } else { "" }; @@ -652,7 +578,7 @@ impl Shell { return Some(( "".into(), "".into(), - vec![("~/".into(), "".into(), true, CompKind::Dir)], + vec![("~/".into(), "".into(), true, CompColor::of_dir())], )); } ("", "/") @@ -709,10 +635,10 @@ impl Shell { format!("{value_prefix}{file_name}{suffix}") }; - let comp_kind = if is_dir { - CompKind::Dir + let comp_color = if is_dir { + CompColor::of_dir() } else if is_symlink { - CompKind::Symlink + CompColor::of_symlink() } else { #[cfg(not(windows))] let is_executable = { @@ -725,13 +651,13 @@ impl Shell { path_exts.iter().any(|v| new_file_name.ends_with(v)) }; if is_executable { - CompKind::FileExe + CompColor::of_file_exe() } else { - CompKind::File + CompColor::of_file() } }; let nospace = if default_nospace { true } else { is_dir }; - output.push((path_value, String::new(), nospace, comp_kind)) + output.push((path_value, String::new(), nospace, comp_color)) } output.sort_by(|a, b| a.0.cmp(&b.0)); @@ -818,16 +744,200 @@ impl Shell { } } +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) struct CompColor { + pub(crate) code: ColorCode, + pub(crate) style: ColorStyle, +} + +impl CompColor { + pub(crate) fn new(code: ColorCode, style: ColorStyle) -> Self { + Self { code, style } + } + + pub(crate) fn deser(s: &str) -> Result { + if let Some((code, style)) = s.split_once(',') { + if let (Ok(code), Ok(style)) = (code.parse(), style.parse()) { + return Ok(Self::new(code, style)); + } + } else if let Ok(code) = s.parse() { + return Ok(Self::new(code, ColorStyle::Regular)); + } + bail!("Invalid CompColor value") + } + + pub(crate) fn ser(&self) -> String { + if self.style == ColorStyle::Regular { + format!("{}", self.code) + } else { + format!("{},{}", self.code, self.style) + } + } + + pub(crate) fn ansi_code(&self) -> String { + let mut ret = if self.style != ColorStyle::Regular { + format!("{};", self.style.ansi_code()) + } else { + String::new() + }; + ret.push_str(self.code.ansi_code()); + ret + } + + pub(crate) fn style(&self) -> String { + let mut ret = self.code.to_string(); + if self.style != ColorStyle::Regular { + ret.push_str(&format!(" {}", self.style)) + } + ret + } + + pub(crate) fn of_flag() -> Self { + Self::new(ColorCode::Cyan, ColorStyle::Regular) + } + + pub(crate) fn of_option() -> Self { + Self::new(ColorCode::Cyan, ColorStyle::Bold) + } + + pub(crate) fn of_command() -> Self { + Self::new(ColorCode::Magenta, ColorStyle::Regular) + } + + pub(crate) fn of_dir() -> Self { + Self::new(ColorCode::Blue, ColorStyle::Bold) + } + + pub(crate) fn of_file() -> Self { + Self::new(ColorCode::Default, ColorStyle::Regular) + } + + pub(crate) fn of_file_exe() -> Self { + Self::new(ColorCode::Green, ColorStyle::Bold) + } + + pub(crate) fn of_symlink() -> Self { + Self::new(ColorCode::Cyan, ColorStyle::Bold) + } + + pub(crate) fn of_value() -> Self { + Self::new(ColorCode::Green, ColorStyle::Regular) + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum ColorCode { + Black, + Red, + Green, + Yellow, + Blue, + Magenta, + Cyan, + White, + Default, +} + +impl FromStr for ColorCode { + type Err = anyhow::Error; + + fn from_str(s: &str) -> std::result::Result { + match s { + "black" => Ok(Self::Black), + "red" => Ok(Self::Red), + "green" => Ok(Self::Green), + "yellow" => Ok(Self::Yellow), + "blue" => Ok(Self::Blue), + "magenta" => Ok(Self::Magenta), + "cyan" => Ok(Self::Cyan), + "white" => Ok(Self::White), + "default" => Ok(Self::Default), + _ => bail!("Invalid ColorCode value"), + } + } +} + +impl fmt::Display for ColorCode { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Black => write!(f, "black"), + Self::Red => write!(f, "red"), + Self::Green => write!(f, "green"), + Self::Yellow => write!(f, "yellow"), + Self::Blue => write!(f, "blue"), + Self::Magenta => write!(f, "magenta"), + Self::Cyan => write!(f, "cyan"), + Self::White => write!(f, "white"), + Self::Default => write!(f, "default"), + } + } +} + +impl ColorCode { + pub fn ansi_code(&self) -> &str { + match self { + Self::Black => "30", + Self::Red => "31", + Self::Green => "32", + Self::Yellow => "33", + Self::Blue => "34", + Self::Magenta => "35", + Self::Cyan => "36", + Self::White => "37", + Self::Default => "39", + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum ColorStyle { + Regular, + Bold, +} + +impl FromStr for ColorStyle { + type Err = anyhow::Error; + + fn from_str(s: &str) -> std::result::Result { + match s { + "regular" => Ok(Self::Regular), + "bold" => Ok(Self::Bold), + _ => bail!("Invalid CodeStyle value"), + } + } +} + +impl fmt::Display for ColorStyle { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Regular => write!(f, "regular"), + Self::Bold => write!(f, "bold"), + } + } +} + +impl ColorStyle { + pub fn ansi_code(&self) -> &str { + match self { + Self::Regular => "0", + Self::Bold => "1", + } + } +} + fn parse_candidate_value(input: &str) -> CandidateValue { let parts: Vec<&str> = input.split('\t').collect(); let parts_len = parts.len(); let mut value = String::new(); let mut description = String::new(); let mut nospace = false; - let mut comp_kind = CompKind::Value; + let mut comp_color = CompColor::of_value(); if parts_len >= 2 { - if let Some(kind_value) = parts[1].strip_prefix("/kind:").and_then(|v| v.parse().ok()) { - comp_kind = kind_value; + if let Some(color) = parts[1] + .strip_prefix("/color:") + .and_then(|v| CompColor::deser(v).ok()) + { + comp_color = color; description = parts[2..].join("\t"); } else { description = parts[1..].join("\t"); @@ -841,7 +951,7 @@ fn parse_candidate_value(input: &str) -> CandidateValue { value = parts[0].trim().to_string(); } } - (value, description, nospace, comp_kind) + (value, description, nospace, comp_color) } fn convert_arg_value(value: &str) -> Option { @@ -965,44 +1075,62 @@ mod tests { use super::*; macro_rules! assert_parse_candidate_value { - ($input:expr, $value:expr, $desc:expr, $nospace:expr, $comp_kind:expr) => { + ($input:expr, $value:expr, $desc:expr, $nospace:expr, $comp_color:expr) => { assert_eq!( parse_candidate_value($input), - ($value.to_string(), $desc.to_string(), $nospace, $comp_kind) + ($value.to_string(), $desc.to_string(), $nospace, $comp_color) ) }; } #[test] fn test_parse_candidate_value() { - assert_parse_candidate_value!("abc", "abc", "", false, CompKind::Value); - assert_parse_candidate_value!("abc\0", "abc", "", true, CompKind::Value); - assert_parse_candidate_value!("abc\tA value", "abc", "A value", false, CompKind::Value); - assert_parse_candidate_value!("abc\0\tA value", "abc", "A value", true, CompKind::Value); + assert_parse_candidate_value!("abc", "abc", "", false, CompColor::of_value()); + assert_parse_candidate_value!("abc\0", "abc", "", true, CompColor::of_value()); + assert_parse_candidate_value!( + "abc\tA value", + "abc", + "A value", + false, + CompColor::of_value() + ); + assert_parse_candidate_value!( + "abc\0\tA value", + "abc", + "A value", + true, + CompColor::of_value() + ); assert_parse_candidate_value!( "abc\0\tA value\tmore desc", "abc", "A value\tmore desc", true, - CompKind::Value + CompColor::of_value() ); assert_parse_candidate_value!( - "abc\0\t/kind:command\tA value\tmore desc", + "abc\0\t/color:magenta\tA value\tmore desc", "abc", "A value\tmore desc", true, - CompKind::Command + CompColor::of_command() ); assert_parse_candidate_value!( - "abc\0\t/kind:command\tA value", + "abc\0\t/color:cyan,bold\tA value", "abc", "A value", true, - CompKind::Command + CompColor::of_option() + ); + assert_parse_candidate_value!("abc\0\t/color:cyan", "abc", "", true, CompColor::of_flag()); + assert_parse_candidate_value!( + "abc\t/color:default", + "abc", + "", + false, + CompColor::of_file() ); - assert_parse_candidate_value!("abc\0\t/kind:command", "abc", "", true, CompKind::Command); - assert_parse_candidate_value!("abc\t/kind:command", "abc", "", false, CompKind::Command); - assert_parse_candidate_value!("", "", "", false, CompKind::Value); + assert_parse_candidate_value!("", "", "", false, CompColor::of_value()); } #[test] diff --git a/src/matcher.rs b/src/matcher.rs index 001bba8c..8f133c30 100644 --- a/src/matcher.rs +++ b/src/matcher.rs @@ -6,7 +6,7 @@ use std::{ use crate::{ command::Command, - compgen::CompKind, + compgen::CompColor, param::{FlagOptionParam, PositionalParam}, utils::run_param_fns, ArgcValue, Shell, @@ -251,7 +251,11 @@ impl<'a, 'b> Matcher<'a, 'b> { .iter() .any(|v| redirect_symbols.contains(&v.as_str())) { - return vec![("__argc_value=path".into(), String::new(), CompKind::Value)]; + return vec![( + "__argc_value=path".into(), + String::new(), + CompColor::of_value(), + )]; } let level = self.cmds.len() - 1; let mut last_cmd = self.cmds[level].1; @@ -272,9 +276,9 @@ impl<'a, 'b> Matcher<'a, 'b> { { let describe = param.describe_head(); let kind = if param.is_flag() { - CompKind::Flag + CompColor::of_flag() } else { - CompKind::Option + CompColor::of_option() }; output.push((value.clone(), describe.into(), kind)); } @@ -293,7 +297,7 @@ impl<'a, 'b> Matcher<'a, 'b> { }) .collect(); if output.len() == 1 { - output.insert(0, (value.to_string(), String::new(), CompKind::Flag)); + output.insert(0, (value.to_string(), String::new(), CompColor::of_flag())); } output } @@ -329,7 +333,11 @@ impl<'a, 'b> Matcher<'a, 'b> { && !self.arg_comp.is_flag_or_option() && last_cmd.positional_params.is_empty() { - output.push(("__argc_value=path".into(), String::new(), CompKind::Value)); + output.push(( + "__argc_value=path".into(), + String::new(), + CompColor::of_value(), + )); } output } @@ -760,9 +768,9 @@ impl<'a, 'b> Matcher<'a, 'b> { if !exist || param.multiple { let describe = param.describe_head(); let kind = if param.is_flag() { - CompKind::Flag + CompColor::of_flag() } else { - CompKind::Option + CompColor::of_option() }; for v in param.list_names() { output.push((v, describe.to_string(), kind)) @@ -773,7 +781,7 @@ impl<'a, 'b> Matcher<'a, 'b> { } } -pub(crate) type CompItem = (String, String, CompKind); +pub(crate) type CompItem = (String, String, CompColor); fn add_positional_arg<'a>( positional_args: &mut Vec<&'a str>, @@ -886,7 +894,7 @@ fn comp_subcomands(cmd: &Command) -> Vec { for subcmd in cmd.subcommands.iter() { let describe = subcmd.describe_head(); for v in subcmd.list_names() { - output.push((v, describe.to_string(), CompKind::Command)) + output.push((v, describe.to_string(), CompColor::of_command())) } } output @@ -935,17 +943,17 @@ fn comp_param( match choices { Either::Left(choices) => choices .iter() - .map(|v| (v.to_string(), String::new(), CompKind::Value)) + .map(|v| (v.to_string(), String::new(), CompColor::of_value())) .collect(), Either::Right(choices_fn) => vec![( format!("__argc_fn={}", choices_fn), String::new(), - CompKind::Value, + CompColor::of_value(), )], } } else { let value = format!("__argc_value={}", value_name); - vec![(value, describe.into(), CompKind::Value)] + vec![(value, describe.into(), CompColor::of_value())] }; if let Some(ch) = multi_char { output.insert( @@ -953,7 +961,7 @@ fn comp_param( ( format!("__argc_multi={}", ch), String::new(), - CompKind::Value, + CompColor::of_value(), ), ); } diff --git a/tests/compgen.rs b/tests/compgen.rs index 047de030..95ae15ac 100644 --- a/tests/compgen.rs +++ b/tests/compgen.rs @@ -740,7 +740,7 @@ _choice_fn() { echo -e "c1\t" echo -e "d1\0" echo -e "e1" - echo -e "f1\t/kind:valueOther\tdesc f1" + echo -e "f1\t/color:yellow\tdesc f1" } "###; @@ -768,18 +768,32 @@ fn color() { let script = r###" # @arg val[`_fn_color`] _fn_color() { - echo -e "flag\0\t/kind:flag" - echo -e "option\0\t/kind:option" - echo -e "command\0\t/kind:command" - echo -e "dir\0\t/kind:dir" - echo -e "file\0\t/kind:file" - echo -e "fileExe\0\t/kind:fileExe" - echo -e "symlink\0\t/kind:symlink" - echo -e "valueOther\0\t/kind:valueOther" - echo -e "valueAnother\0\t/kind:valueAnother" - echo -e "valueEmphasis\0\t/kind:valueEmphasis" - echo -e "valueSubtle\0\t/kind:valueSubtle" - echo -e "value\0\t/kind:value" + echo -e "kindFlag\0\t/color:cyan" + echo -e "kindOption\0\t/color:cyan,bold" + echo -e "kindCommand\0\t/color:magenta" + echo -e "kindDir\0\t/color:blue,bold" + echo -e "kindFile\0\t/color:default" + echo -e "kindFileExe\0\t/color:green,bold" + echo -e "kindSymlink\0\t/color:cyan,bold" + echo -e "kindValue\0\t/color:green" + echo -e "colorBlack\0\t/color:black" + echo -e "colorBlackBold\0\t/color:black,bold" + echo -e "colorRed\0\t/color:red" + echo -e "colorRedBold\0\t/color:red,bold" + echo -e "colorGreen\0\t/color:green" + echo -e "colorGreenBold\0\t/color:green,bold" + echo -e "colorYellow\0\t/color:yellow" + echo -e "colorYellowBold\0\t/color:yellow,bold" + echo -e "colorBlue\0\t/color:blue" + echo -e "colorBlueBold\0\t/color:blue,bold" + echo -e "colorMagenta\0\t/color:magenta" + echo -e "colorMagentaBold\0\t/color:magenta,bold" + echo -e "colorCyan\0\t/color:cyan" + echo -e "colorCyanBold\0\t/color:cyan,bold" + echo -e "colorWhite\0\t/color:white" + echo -e "colorWhiteBold\0\t/color:white,bold" + echo -e "colorDefault\0\t/color:default" + echo -e "colorDefaultBold\0\t/color:default,bold" } "###; snapshot_compgen_shells!(script, vec!["prog", ""]); diff --git a/tests/snapshots/integration__compgen__arg_terminated.snap b/tests/snapshots/integration__compgen__arg_terminated.snap index ff7264dc..a76464ff 100644 --- a/tests/snapshots/integration__compgen__arg_terminated.snap +++ b/tests/snapshots/integration__compgen__arg_terminated.snap @@ -3,28 +3,28 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `sudo cmd ` ************ -__argc_filter= /kind:value -cmd /kind:value -ok /kind:value +__argc_filter= /color:green +cmd /color:green +ok /color:green ************ COMPGEN `sudo cmd -` ************ -__argc_filter= /kind:value -cmd - /kind:value -ok /kind:value +__argc_filter= /color:green +cmd - /color:green +ok /color:green ************ COMPGEN `sudo cmd --` ************ -__argc_filter= /kind:value -cmd -- /kind:value -ok /kind:value +__argc_filter= /color:green +cmd -- /color:green +ok /color:green ************ COMPGEN `sudo cmd --foo` ************ -__argc_filter= /kind:value -cmd --foo /kind:value -ok /kind:value +__argc_filter= /color:green +cmd --foo /color:green +ok /color:green ************ COMPGEN `sudo cmd foo` ************ -__argc_filter= /kind:value -cmd foo /kind:value -ok /kind:value +__argc_filter= /color:green +cmd foo /color:green +ok /color:green diff --git a/tests/snapshots/integration__compgen__assing_option_value.snap b/tests/snapshots/integration__compgen__assing_option_value.snap index ae602791..72ffe18c 100644 --- a/tests/snapshots/integration__compgen__assing_option_value.snap +++ b/tests/snapshots/integration__compgen__assing_option_value.snap @@ -3,25 +3,25 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog --oa=abc` ************ -__argc_filter= /kind:value -ARGC_COMPGEN=1 /kind:value -ARGC_FILTER=abc /kind:value -ARGC_LAST_ARG=--oa=abc /kind:value -ARGC_VARS=YXJnY19vYT1hYmM7YXJnY19fYXJncz0oIHByb2cgJy0tb2E9YWJjJyApO2FyZ2NfX2luZGV4PTA7YXJnY19fcG9zaXRpb25hbHM9KCAgKTs= /kind:value -argc__args=([0]="prog" [1]="--oa=abc") /kind:value -argc__index=0 /kind:value -argc__positionals=() /kind:value -argc_oa=abc /kind:value +__argc_filter= /color:green +ARGC_COMPGEN=1 /color:green +ARGC_FILTER=abc /color:green +ARGC_LAST_ARG=--oa=abc /color:green +ARGC_VARS=YXJnY19vYT1hYmM7YXJnY19fYXJncz0oIHByb2cgJy0tb2E9YWJjJyApO2FyZ2NfX2luZGV4PTA7YXJnY19fcG9zaXRpb25hbHM9KCAgKTs= /color:green +argc__args=([0]="prog" [1]="--oa=abc") /color:green +argc__index=0 /color:green +argc__positionals=() /color:green +argc_oa=abc /color:green ************ COMPGEN `prog oa=abc` ************ -__argc_filter= /kind:value -ARGC_COMPGEN=1 /kind:value -ARGC_FILTER=oa=abc /kind:value -ARGC_LAST_ARG=oa=abc /kind:value -ARGC_VARS=YXJnY192YWw9J29hPWFiYyc7YXJnY19fYXJncz0oIHByb2cgJ29hPWFiYycgKTthcmdjX19pbmRleD0wO2FyZ2NfX3Bvc2l0aW9uYWxzPSggJ29hPWFiYycgKTs= /kind:value -argc__args=([0]="prog" [1]="oa=abc") /kind:value -argc__index=0 /kind:value -argc__positionals=([0]="oa=abc") /kind:value -argc_val=oa=abc /kind:value +__argc_filter= /color:green +ARGC_COMPGEN=1 /color:green +ARGC_FILTER=oa=abc /color:green +ARGC_LAST_ARG=oa=abc /color:green +ARGC_VARS=YXJnY192YWw9J29hPWFiYyc7YXJnY19fYXJncz0oIHByb2cgJ29hPWFiYycgKTthcmdjX19pbmRleD0wO2FyZ2NfX3Bvc2l0aW9uYWxzPSggJ29hPWFiYycgKTs= /color:green +argc__args=([0]="prog" [1]="oa=abc") /color:green +argc__index=0 /color:green +argc__positionals=([0]="oa=abc") /color:green +argc_val=oa=abc /color:green diff --git a/tests/snapshots/integration__compgen__choice.snap b/tests/snapshots/integration__compgen__choice.snap index da4b2378ad73ae57de5316d31d2ba675254902b7..cceb9ed47fc760eb7dbb6cc0ae038de713461dc3 100644 GIT binary patch literal 1176 zcmcgqy$ZrG5Oy_BakvP@D6WN0B2NB1Len(Hf;J_oQhj=(U7DjbN=vidaryr4D5b=x zyXGQ>~yXeEJC#UO^pKtNc+ zrxx?7bSSkDIZ4IYZOBXJHhdJ(2o%i6;S&iFh9I6V368FEV|lve%PqUWk(a@6A8Ram z;BC)87uB-viR;~-6zbTULY=OBY8t#R>*WuO**H>bntoEPQr@ySWVUapUlyC;0$txv Gxa18M$3E@= literal 1147 zcmcgq%MOAt5cF!lV&lbxScz8>PR4lh@d=btk*JikK+vzZ%7twRkbw5Ko9*oE%uq^+ zmWATNgIwrbyIel9Sfp#EiKsFqv`%E|LBw)KsF`*e54NYndA~bCkSQ4hrIJAajRA+S zkk8#)l15(1?u8(cxS%?|CaCVi_kWGgdKUB%1m8v=JzqjwvkEElMAZvbUC7oQ(}0#6 zo9vVZFFy%tad?J~HW9)NlOf#blBM2Zdt|N{4zc(H&3eZunuaBBaSPu$PR#ELqut61 I+W=JZ2G-m%l>h($ diff --git a/tests/snapshots/integration__compgen__choice_check_vars.snap b/tests/snapshots/integration__compgen__choice_check_vars.snap index 523f7a34..3fdfaf59 100644 --- a/tests/snapshots/integration__compgen__choice_check_vars.snap +++ b/tests/snapshots/integration__compgen__choice_check_vars.snap @@ -3,23 +3,23 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog argc` ************ -argc__args=([0]="prog" [1]="argc") /kind:value -argc__index=0 /kind:value -argc__positionals=([0]="argc") /kind:value -argc_foo=argc /kind:value +argc__args=([0]="prog" [1]="argc") /color:green +argc__index=0 /color:green +argc__positionals=([0]="argc") /color:green +argc_foo=argc /color:green ************ COMPGEN `prog argc ` ************ -argc__args=([0]="prog" [1]="argc" [2]="") /kind:value -argc__index=0 /kind:value -argc__positionals=([0]="argc" [1]="") /kind:value -argc_bar= /kind:value -argc_foo=argc /kind:value +argc__args=([0]="prog" [1]="argc" [2]="") /color:green +argc__index=0 /color:green +argc__positionals=([0]="argc" [1]="") /color:green +argc_bar= /color:green +argc_foo=argc /color:green ************ COMPGEN `prog argc argc` ************ -argc__args=([0]="prog" [1]="argc" [2]="argc") /kind:value -argc__index=0 /kind:value -argc__positionals=([0]="argc" [1]="argc") /kind:value -argc_bar=argc /kind:value -argc_foo=argc /kind:value +argc__args=([0]="prog" [1]="argc" [2]="argc") /color:green +argc__index=0 /color:green +argc__positionals=([0]="argc" [1]="argc") /color:green +argc_bar=argc /color:green +argc_foo=argc /color:green diff --git a/tests/snapshots/integration__compgen__choice_multi.snap b/tests/snapshots/integration__compgen__choice_multi.snap index 92f29ec7..d3564d81 100644 --- a/tests/snapshots/integration__compgen__choice_multi.snap +++ b/tests/snapshots/integration__compgen__choice_multi.snap @@ -3,13 +3,13 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog --oa ` ************ -abc /kind:value -def /kind:value -ghi /kind:value +abc /color:green +def /color:green +ghi /color:green ************ COMPGEN `prog --oa=` ************ -abc /kind:value -def /kind:value -ghi /kind:value +abc /color:green +def /color:green +ghi /color:green diff --git a/tests/snapshots/integration__compgen__choice_slash.snap b/tests/snapshots/integration__compgen__choice_slash.snap index 68a29d9d..10c30f17 100644 --- a/tests/snapshots/integration__compgen__choice_slash.snap +++ b/tests/snapshots/integration__compgen__choice_slash.snap @@ -3,6 +3,6 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog cmd a\b ` ************ -a\b /kind:value +a\b /color:green diff --git a/tests/snapshots/integration__compgen__color.snap b/tests/snapshots/integration__compgen__color.snap index b28b42d7..85037003 100644 --- a/tests/snapshots/integration__compgen__color.snap +++ b/tests/snapshots/integration__compgen__color.snap @@ -3,101 +3,199 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN Bash `prog ` ************ -flag -option -command -dir -file -fileExe -symlink -valueOther -valueAnother -valueEmphasis -valueSubtle -value +kindFlag +kindOption +kindCommand +kindDir +kindFile +kindFileExe +kindSymlink +kindValue +colorBlack +colorBlackBold +colorRed +colorRedBold +colorGreen +colorGreenBold +colorYellow +colorYellowBold +colorBlue +colorBlueBold +colorMagenta +colorMagentaBold +colorCyan +colorCyanBold +colorWhite +colorWhiteBold +colorDefault +colorDefaultBold ************ COMPGEN Elvish `prog ` ************ -flag 0 flag cyan -option 0 option cyan bold -command 0 command magenta -dir 0 dir blue bold -file 0 file default -fileExe 0 fileExe green bold -symlink 0 symlink cyan bold -valueOther 0 valueOther yellow -valueAnother 0 valueAnother red -valueEmphasis 0 valueEmphasis green bold -valueSubtle 0 valueSubtle green dim -value 0 value green +kindFlag 0 kindFlag cyan +kindOption 0 kindOption cyan bold +kindCommand 0 kindCommand magenta +kindDir 0 kindDir blue bold +kindFile 0 kindFile default +kindFileExe 0 kindFileExe green bold +kindSymlink 0 kindSymlink cyan bold +kindValue 0 kindValue green +colorBlack 0 colorBlack black +colorBlackBold 0 colorBlackBold black bold +colorRed 0 colorRed red +colorRedBold 0 colorRedBold red bold +colorGreen 0 colorGreen green +colorGreenBold 0 colorGreenBold green bold +colorYellow 0 colorYellow yellow +colorYellowBold 0 colorYellowBold yellow bold +colorBlue 0 colorBlue blue +colorBlueBold 0 colorBlueBold blue bold +colorMagenta 0 colorMagenta magenta +colorMagentaBold 0 colorMagentaBold magenta bold +colorCyan 0 colorCyan cyan +colorCyanBold 0 colorCyanBold cyan bold +colorWhite 0 colorWhite white +colorWhiteBold 0 colorWhiteBold white bold +colorDefault 0 colorDefault default +colorDefaultBold 0 colorDefaultBold default bold ************ COMPGEN Fish `prog ` ************ -flag -option -command -dir -file -fileExe -symlink -valueOther -valueAnother -valueEmphasis -valueSubtle -value +kindFlag +kindOption +kindCommand +kindDir +kindFile +kindFileExe +kindSymlink +kindValue +colorBlack +colorBlackBold +colorRed +colorRedBold +colorGreen +colorGreenBold +colorYellow +colorYellowBold +colorBlue +colorBlueBold +colorMagenta +colorMagentaBold +colorCyan +colorCyanBold +colorWhite +colorWhiteBold +colorDefault +colorDefaultBold ************ COMPGEN Nushell `prog ` ************ -flag -option -command -dir -file -fileExe -symlink -valueOther -valueAnother -valueEmphasis -valueSubtle -value +kindFlag +kindOption +kindCommand +kindDir +kindFile +kindFileExe +kindSymlink +kindValue +colorBlack +colorBlackBold +colorRed +colorRedBold +colorGreen +colorGreenBold +colorYellow +colorYellowBold +colorBlue +colorBlueBold +colorMagenta +colorMagentaBold +colorCyan +colorCyanBold +colorWhite +colorWhiteBold +colorDefault +colorDefaultBold ************ COMPGEN Powershell `prog ` ************ -flag 0 flag 36 -option 0 option 1;36 -command 0 command 35 -dir 0 dir 1;34 -file 0 file 39 -fileExe 0 fileExe 1;32 -symlink 0 symlink 1;36 -valueOther 0 valueOther 33 -valueAnother 0 valueAnother 31 -valueEmphasis 0 valueEmphasis 1;32 -valueSubtle 0 valueSubtle 2;32 -value 0 value 32 +kindFlag 0 kindFlag 36 +kindOption 0 kindOption 1;36 +kindCommand 0 kindCommand 35 +kindDir 0 kindDir 1;34 +kindFile 0 kindFile 39 +kindFileExe 0 kindFileExe 1;32 +kindSymlink 0 kindSymlink 1;36 +kindValue 0 kindValue 32 +colorBlack 0 colorBlack 30 +colorBlackBold 0 colorBlackBold 1;30 +colorRed 0 colorRed 31 +colorRedBold 0 colorRedBold 1;31 +colorGreen 0 colorGreen 32 +colorGreenBold 0 colorGreenBold 1;32 +colorYellow 0 colorYellow 33 +colorYellowBold 0 colorYellowBold 1;33 +colorBlue 0 colorBlue 34 +colorBlueBold 0 colorBlueBold 1;34 +colorMagenta 0 colorMagenta 35 +colorMagentaBold 0 colorMagentaBold 1;35 +colorCyan 0 colorCyan 36 +colorCyanBold 0 colorCyanBold 1;36 +colorWhite 0 colorWhite 37 +colorWhiteBold 0 colorWhiteBold 1;37 +colorDefault 0 colorDefault 39 +colorDefaultBold 0 colorDefaultBold 1;39 ************ COMPGEN Xonsh `prog ` ************ -flag 0 flag -option 0 option -command 0 command -dir 0 dir -file 0 file -fileExe 0 fileExe -symlink 0 symlink -valueOther 0 valueOther -valueAnother 0 valueAnother -valueEmphasis 0 valueEmphasis -valueSubtle 0 valueSubtle -value 0 value +kindFlag 0 kindFlag +kindOption 0 kindOption +kindCommand 0 kindCommand +kindDir 0 kindDir +kindFile 0 kindFile +kindFileExe 0 kindFileExe +kindSymlink 0 kindSymlink +kindValue 0 kindValue +colorBlack 0 colorBlack +colorBlackBold 0 colorBlackBold +colorRed 0 colorRed +colorRedBold 0 colorRedBold +colorGreen 0 colorGreen +colorGreenBold 0 colorGreenBold +colorYellow 0 colorYellow +colorYellowBold 0 colorYellowBold +colorBlue 0 colorBlue +colorBlueBold 0 colorBlueBold +colorMagenta 0 colorMagenta +colorMagentaBold 0 colorMagentaBold +colorCyan 0 colorCyan +colorCyanBold 0 colorCyanBold +colorWhite 0 colorWhite +colorWhiteBold 0 colorWhiteBold +colorDefault 0 colorDefault +colorDefaultBold 0 colorDefaultBold ************ COMPGEN Zsh `prog ` ************ -flag flag flag 36 -option option option 1;36 -command command command 35 -dir dir dir 1;34 -file file file 39 -fileExe fileExe fileExe 1;32 -symlink symlink symlink 1;36 -valueOther valueOther valueOther 33 -valueAnother valueAnother valueAnother 31 -valueEmphasis valueEmphasis valueEmphasis 1;32 -valueSubtle valueSubtle valueSubtle 2;32 -value value value 32 +kindFlag kindFlag kindFlag 36 +kindOption kindOption kindOption 1;36 +kindCommand kindCommand kindCommand 35 +kindDir kindDir kindDir 1;34 +kindFile kindFile kindFile 39 +kindFileExe kindFileExe kindFileExe 1;32 +kindSymlink kindSymlink kindSymlink 1;36 +kindValue kindValue kindValue 32 +colorBlack colorBlack colorBlack 30 +colorBlackBold colorBlackBold colorBlackBold 1;30 +colorRed colorRed colorRed 31 +colorRedBold colorRedBold colorRedBold 1;31 +colorGreen colorGreen colorGreen 32 +colorGreenBold colorGreenBold colorGreenBold 1;32 +colorYellow colorYellow colorYellow 33 +colorYellowBold colorYellowBold colorYellowBold 1;33 +colorBlue colorBlue colorBlue 34 +colorBlueBold colorBlueBold colorBlueBold 1;34 +colorMagenta colorMagenta colorMagenta 35 +colorMagentaBold colorMagentaBold colorMagentaBold 1;35 +colorCyan colorCyan colorCyan 36 +colorCyanBold colorCyanBold colorCyanBold 1;36 +colorWhite colorWhite colorWhite 37 +colorWhiteBold colorWhiteBold colorWhiteBold 1;37 +colorDefault colorDefault colorDefault 39 +colorDefaultBold colorDefaultBold colorDefaultBold 1;39 diff --git a/tests/snapshots/integration__compgen__fallback_comp_file.snap b/tests/snapshots/integration__compgen__fallback_comp_file.snap index ad77e455..c1f453e2 100644 --- a/tests/snapshots/integration__compgen__fallback_comp_file.snap +++ b/tests/snapshots/integration__compgen__fallback_comp_file.snap @@ -3,21 +3,21 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog args ` ************ -__argc_value=path /kind:value +__argc_value=path /color:green ************ COMPGEN `prog args v` ************ -__argc_value=path /kind:value +__argc_value=path /color:green ************ COMPGEN `prog cmd --file ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog cmd --file v` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog cmd --value ` ************ -__argc_value=VALUE /kind:value +__argc_value=VALUE /color:green ************ COMPGEN `prog cmd --value v` ************ -__argc_value=VALUE /kind:value +__argc_value=VALUE /color:green diff --git a/tests/snapshots/integration__compgen__just_match.snap b/tests/snapshots/integration__compgen__just_match.snap index 0c36f932..f3ad9122 100644 --- a/tests/snapshots/integration__compgen__just_match.snap +++ b/tests/snapshots/integration__compgen__just_match.snap @@ -3,7 +3,7 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog --oa` ************ ---oa-file /kind:option ---oa /kind:option +--oa-file /color:cyan,bold +--oa /color:cyan,bold diff --git a/tests/snapshots/integration__compgen__last_arg_option_assign.snap b/tests/snapshots/integration__compgen__last_arg_option_assign.snap index 85558e57..35fc78f7 100644 --- a/tests/snapshots/integration__compgen__last_arg_option_assign.snap +++ b/tests/snapshots/integration__compgen__last_arg_option_assign.snap @@ -3,14 +3,14 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog --ob=` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog --oa --ob=` ************ -__argc_filter= /kind:value -ok /kind:value +__argc_filter= /color:green +ok /color:green ************ COMPGEN `prog abc --ob=` ************ -__argc_filter= /kind:value -ok /kind:value +__argc_filter= /color:green +ok /color:green diff --git a/tests/snapshots/integration__compgen__multiline_doc.snap b/tests/snapshots/integration__compgen__multiline_doc.snap index 5cc57a84..0e66e8fb 100644 --- a/tests/snapshots/integration__compgen__multiline_doc.snap +++ b/tests/snapshots/integration__compgen__multiline_doc.snap @@ -3,10 +3,10 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog ` ************ -cmda /kind:command cmd-line1 -cmdb /kind:command line +cmda /color:magenta cmd-line1 +cmdb /color:magenta line ************ COMPGEN `prog cmda ` ************ -__argc_value=BAR /kind:value +__argc_value=BAR /color:green diff --git a/tests/snapshots/integration__compgen__multiple.snap b/tests/snapshots/integration__compgen__multiple.snap index 366dd33d..75b96ec0 100644 --- a/tests/snapshots/integration__compgen__multiple.snap +++ b/tests/snapshots/integration__compgen__multiple.snap @@ -3,67 +3,67 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog -` ************ ---fc /kind:flag --f /kind:flag ---oa /kind:option --o /kind:option ---od /kind:option --d /kind:option +--fc /color:cyan +-f /color:cyan +--oa /color:cyan,bold +-o /color:cyan,bold +--od /color:cyan,bold +-d /color:cyan,bold ************ COMPGEN `prog --` ************ ---fc /kind:flag ---oa /kind:option ---od /kind:option +--fc /color:cyan +--oa /color:cyan,bold +--od /color:cyan,bold ************ COMPGEN `prog -- ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog -f ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog --fc ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog -o ` ************ -__argc_value=DIR /kind:value +__argc_value=DIR /color:green ************ COMPGEN `prog -o d1` ************ -__argc_value=DIR /kind:value +__argc_value=DIR /color:green ************ COMPGEN `prog -o d1 ` ************ -__argc_value=DIR /kind:value +__argc_value=DIR /color:green ************ COMPGEN `prog -o d1 d2` ************ -__argc_value=DIR /kind:value +__argc_value=DIR /color:green ************ COMPGEN `prog -o d1 d2 ` ************ -__argc_value=DIR /kind:value +__argc_value=DIR /color:green ************ COMPGEN `prog -d d1` ************ -__argc_value=DIR /kind:value +__argc_value=DIR /color:green ************ COMPGEN `prog -d d1 ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog -d d1 d2` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog -d d1 d2 ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog v1` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog v1 ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog v1 v2` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog v1 v2 ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green diff --git a/tests/snapshots/integration__compgen__nested_subcmds.snap b/tests/snapshots/integration__compgen__nested_subcmds.snap index 9333ebbf..6a354384 100644 --- a/tests/snapshots/integration__compgen__nested_subcmds.snap +++ b/tests/snapshots/integration__compgen__nested_subcmds.snap @@ -3,32 +3,32 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog ` ************ -__argc_value=FILE /kind:value -cmd /kind:command +__argc_value=FILE /color:green +cmd /color:magenta ************ COMPGEN `prog cmd` ************ -cmd /kind:command +cmd /color:magenta ************ COMPGEN `prog cmd ` ************ -suba /kind:command -subb /kind:command +suba /color:magenta +subb /color:magenta ************ COMPGEN `prog cmd s` ************ -suba /kind:command -subb /kind:command +suba /color:magenta +subb /color:magenta ************ COMPGEN `prog cmd suba` ************ -suba /kind:command +suba /color:magenta ************ COMPGEN `prog cmd suba ` ************ -__argc_value=path /kind:value +__argc_value=path /color:green ************ COMPGEN `prog cmd help ` ************ -suba /kind:command -subb /kind:command +suba /color:magenta +subb /color:magenta ************ COMPGEN `prog cmd help s` ************ -suba /kind:command -subb /kind:command +suba /color:magenta +subb /color:magenta diff --git a/tests/snapshots/integration__compgen__no_comp_subcmds.snap b/tests/snapshots/integration__compgen__no_comp_subcmds.snap index 2ea25620..1b0eeb85 100644 --- a/tests/snapshots/integration__compgen__no_comp_subcmds.snap +++ b/tests/snapshots/integration__compgen__no_comp_subcmds.snap @@ -3,13 +3,13 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog ` ************ -cmda /kind:command -cmdb /kind:command +cmda /color:magenta +cmdb /color:magenta ************ COMPGEN `prog cmdx ` ************ -__argc_value=path /kind:value +__argc_value=path /color:green ************ COMPGEN `prog cmdx cmd` ************ -__argc_value=path /kind:value +__argc_value=path /color:green diff --git a/tests/snapshots/integration__compgen__no_flags_options.snap b/tests/snapshots/integration__compgen__no_flags_options.snap index 325bd8d6..2ac4c95a 100644 --- a/tests/snapshots/integration__compgen__no_flags_options.snap +++ b/tests/snapshots/integration__compgen__no_flags_options.snap @@ -3,9 +3,9 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog no_arg ` ************ -__argc_value=path /kind:value +__argc_value=path /color:green ************ COMPGEN `prog arg ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green diff --git a/tests/snapshots/integration__compgen__no_flags_options2.snap b/tests/snapshots/integration__compgen__no_flags_options2.snap index 489aad3c..d8f21034 100644 --- a/tests/snapshots/integration__compgen__no_flags_options2.snap +++ b/tests/snapshots/integration__compgen__no_flags_options2.snap @@ -3,7 +3,7 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog ` ************ -cmda /kind:command -cmdb /kind:command +cmda /color:magenta +cmdb /color:magenta diff --git a/tests/snapshots/integration__compgen__no_param.snap b/tests/snapshots/integration__compgen__no_param.snap index 5375be27..0cf9ca52 100644 --- a/tests/snapshots/integration__compgen__no_param.snap +++ b/tests/snapshots/integration__compgen__no_param.snap @@ -3,6 +3,6 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog cmd ` ************ -__argc_value=path /kind:value +__argc_value=path /color:green diff --git a/tests/snapshots/integration__compgen__one_combine_shorts.snap b/tests/snapshots/integration__compgen__one_combine_shorts.snap index 49c2440c..11eead1c 100644 --- a/tests/snapshots/integration__compgen__one_combine_shorts.snap +++ b/tests/snapshots/integration__compgen__one_combine_shorts.snap @@ -3,7 +3,7 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog -a` ************ --a /kind:flag --ab /kind:flag +-a /color:cyan +-ab /color:cyan diff --git a/tests/snapshots/integration__compgen__one_subcmd_with_options.snap b/tests/snapshots/integration__compgen__one_subcmd_with_options.snap index 9148043f..6694b8f7 100644 --- a/tests/snapshots/integration__compgen__one_subcmd_with_options.snap +++ b/tests/snapshots/integration__compgen__one_subcmd_with_options.snap @@ -3,6 +3,6 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog ` ************ -cmda /kind:command +cmda /color:magenta diff --git a/tests/snapshots/integration__compgen__option_multi_vals.snap b/tests/snapshots/integration__compgen__option_multi_vals.snap index 1caf7803..698589a8 100644 --- a/tests/snapshots/integration__compgen__option_multi_vals.snap +++ b/tests/snapshots/integration__compgen__option_multi_vals.snap @@ -3,12 +3,12 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog --oa ` ************ -__argc_value=DIR /kind:value +__argc_value=DIR /color:green ************ COMPGEN `prog --oa bash ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog --oa bash cmd1 ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green diff --git a/tests/snapshots/integration__compgen__option_terminated.snap b/tests/snapshots/integration__compgen__option_terminated.snap index 3bab9eba..d2c589c5 100644 --- a/tests/snapshots/integration__compgen__option_terminated.snap +++ b/tests/snapshots/integration__compgen__option_terminated.snap @@ -3,22 +3,22 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog --oa` ************ ---oa /kind:option +--oa /color:cyan,bold ************ COMPGEN `prog --oa ` ************ -__argc_filter= /kind:value -ok /kind:value +__argc_filter= /color:green +ok /color:green ************ COMPGEN `prog --oa --` ************ -__argc_filter= /kind:value -ok /kind:value +__argc_filter= /color:green +ok /color:green ************ COMPGEN `prog --oa v1 v2` ************ -__argc_filter= /kind:value -ok /kind:value +__argc_filter= /color:green +ok /color:green ************ COMPGEN `prog --oa -- ` ************ -__argc_filter= /kind:value -ok /kind:value +__argc_filter= /color:green +ok /color:green diff --git a/tests/snapshots/integration__compgen__positionals.snap b/tests/snapshots/integration__compgen__positionals.snap index 2dc89fa4..4d6890e8 100644 --- a/tests/snapshots/integration__compgen__positionals.snap +++ b/tests/snapshots/integration__compgen__positionals.snap @@ -3,54 +3,54 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog cmda ` ************ -__argc_value=DIR /kind:value +__argc_value=DIR /color:green ************ COMPGEN `prog cmda v1` ************ -__argc_value=DIR /kind:value +__argc_value=DIR /color:green ************ COMPGEN `prog cmda v1 ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog cmda v1 v2` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog cmda v1 v2 ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog cmdb ` ************ -__argc_value=DIR1 /kind:value +__argc_value=DIR1 /color:green ************ COMPGEN `prog cmdb v1` ************ -__argc_value=DIR1 /kind:value +__argc_value=DIR1 /color:green ************ COMPGEN `prog cmdb v1 ` ************ -__argc_value=DIR2 /kind:value +__argc_value=DIR2 /color:green ************ COMPGEN `prog cmdb v1 v2` ************ -__argc_value=DIR2 /kind:value +__argc_value=DIR2 /color:green ************ COMPGEN `prog cmdb v1 v2 ` ************ -__argc_value=DIR3 /kind:value +__argc_value=DIR3 /color:green ************ COMPGEN `prog cmdb v1 v2 v3` ************ -__argc_value=DIR3 /kind:value +__argc_value=DIR3 /color:green ************ COMPGEN `prog cmdb v1 v2 v3 ` ************ ************ COMPGEN `prog cmdc ` ************ -__argc_value=DIR /kind:value +__argc_value=DIR /color:green ************ COMPGEN `prog cmdc v1` ************ -__argc_value=DIR /kind:value +__argc_value=DIR /color:green ************ COMPGEN `prog cmdc v1 ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog cmdc v1 v2` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog cmdc v1 v2 ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green diff --git a/tests/snapshots/integration__compgen__shorts.snap b/tests/snapshots/integration__compgen__shorts.snap index 44667b88..673386d5 100644 --- a/tests/snapshots/integration__compgen__shorts.snap +++ b/tests/snapshots/integration__compgen__shorts.snap @@ -3,61 +3,61 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog ` ************ -__argc_value=path /kind:value +__argc_value=path /color:green ************ COMPGEN `prog -` ************ --a /kind:flag ---fb /kind:flag --b /kind:flag ---fc /kind:flag --f /kind:flag --sa /kind:flag --e /kind:option ---oa /kind:option --p /kind:option +-a /color:cyan +--fb /color:cyan +-b /color:cyan +--fc /color:cyan +-f /color:cyan +-sa /color:cyan +-e /color:cyan,bold +--oa /color:cyan,bold +-p /color:cyan,bold ************ COMPGEN `prog --` ************ ---fb /kind:flag ---fc /kind:flag ---oa /kind:option +--fb /color:cyan +--fc /color:cyan +--oa /color:cyan,bold ************ COMPGEN `prog -a` ************ --ab /kind:flag --af /kind:flag --ae /kind:option --ap /kind:option +-ab /color:cyan +-af /color:cyan +-ae /color:cyan,bold +-ap /color:cyan,bold ************ COMPGEN `prog -a ` ************ -__argc_value=path /kind:value +__argc_value=path /color:green ************ COMPGEN `prog -af` ************ --afb /kind:flag --aff /kind:flag --afe /kind:option --afp /kind:option +-afb /color:cyan +-aff /color:cyan +-afe /color:cyan,bold +-afp /color:cyan,bold ************ COMPGEN `prog -af ` ************ -__argc_value=path /kind:value +__argc_value=path /color:green ************ COMPGEN `prog -ae` ************ ************ COMPGEN `prog -ae ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog -abe` ************ ************ COMPGEN `prog -abe ` ************ -__argc_value=FILE /kind:value +__argc_value=FILE /color:green ************ COMPGEN `prog -s` ************ --sa /kind:flag +-sa /color:cyan ************ COMPGEN `prog -sa` ************ --sa /kind:flag +-sa /color:cyan ************ COMPGEN `prog -sa ` ************ -__argc_value=path /kind:value +__argc_value=path /color:green diff --git a/tests/snapshots/integration__compgen__special_arg_name.snap b/tests/snapshots/integration__compgen__special_arg_name.snap index 52c1b127..e5a2c0d5 100644 --- a/tests/snapshots/integration__compgen__special_arg_name.snap +++ b/tests/snapshots/integration__compgen__special_arg_name.snap @@ -3,9 +3,9 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog cmda ` ************ -__argc_value=ARG /kind:value +__argc_value=ARG /color:green ************ COMPGEN `prog cmdb ` ************ -__argc_value=ANY /kind:value +__argc_value=ANY /color:green diff --git a/tests/snapshots/integration__compgen__subcmds.snap b/tests/snapshots/integration__compgen__subcmds.snap index 3130e8ec..b5ed85dd 100644 --- a/tests/snapshots/integration__compgen__subcmds.snap +++ b/tests/snapshots/integration__compgen__subcmds.snap @@ -3,28 +3,28 @@ source: tests/compgen.rs expression: data --- ************ COMPGEN `prog ` ************ -__argc_value=FILE /kind:value -cmda /kind:command -cmdb /kind:command +__argc_value=FILE /color:green +cmda /color:magenta +cmdb /color:magenta ************ COMPGEN `prog c` ************ -__argc_value=FILE /kind:value -cmda /kind:command -cmdb /kind:command +__argc_value=FILE /color:green +cmda /color:magenta +cmdb /color:magenta ************ COMPGEN `prog cmda` ************ -cmda /kind:command +cmda /color:magenta ************ COMPGEN `prog cmda ` ************ -__argc_value=path /kind:value +__argc_value=path /color:green ************ COMPGEN `prog help ` ************ -cmda /kind:command -cmdb /kind:command +cmda /color:magenta +cmdb /color:magenta ************ COMPGEN `prog help c` ************ -cmda /kind:command -cmdb /kind:command +cmda /color:magenta +cmdb /color:magenta ************ COMPGEN `prog help cmda ` ************