From 78f52be69e0c31c510f536893aaacb11c5025ea9 Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Sat, 9 Sep 2023 12:46:03 -0400 Subject: [PATCH 01/18] WIP draft command color --- src/color.rs | 12 +++++++++--- src/config.rs | 44 ++++++++++++++++++++++++++++++++++++++++---- src/recipe.rs | 2 +- tests/command.rs | 2 +- 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/src/color.rs b/src/color.rs index 2fcad9a8f2..7eedc4a795 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,3 +1,4 @@ +use ansi_term::Colour; use { super::*, ansi_term::{ANSIGenericString, Color::*, Prefix, Style, Suffix}, @@ -76,8 +77,13 @@ impl Color { self.restyle(Style::new().fg(Cyan).bold()) } - pub(crate) fn command(self) -> Self { - self.restyle(Style::new().bold()) + pub(crate) fn command(self, foreground_color: Option) -> Self { + let new_style = if let Some(fg) = foreground_color { + Style::new().fg(fg).bold() + } else { + Style::new().bold() + }; + self.restyle(new_style) } pub(crate) fn parameter(self) -> Self { @@ -85,7 +91,7 @@ impl Color { } pub(crate) fn message(self) -> Self { - self.restyle(Style::new().bold()) + self.restyle(Style::new().fg(Purple).bold()) } pub(crate) fn annotation(self) -> Self { diff --git a/src/config.rs b/src/config.rs index 70cb43fa2a..118c1a1907 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,3 +1,4 @@ +use ansi_term::Colour; use { super::*, clap::{App, AppSettings, Arg, ArgGroup, ArgMatches, ArgSettings}, @@ -15,6 +16,7 @@ pub(crate) const CHOOSE_HELP: &str = "Select one or more recipes to run using a pub(crate) struct Config { pub(crate) check: bool, pub(crate) color: Color, + pub(crate) command_color: Option, pub(crate) dotenv_filename: Option, pub(crate) dotenv_path: Option, pub(crate) dry_run: bool, @@ -85,6 +87,7 @@ mod arg { pub(crate) const CHOOSER: &str = "CHOOSER"; pub(crate) const CLEAR_SHELL_ARGS: &str = "CLEAR-SHELL-ARGS"; pub(crate) const COLOR: &str = "COLOR"; + pub(crate) const COMMAND_COLOR: &str = "COMMAND-COLOR"; pub(crate) const DOTENV_FILENAME: &str = "DOTENV-FILENAME"; pub(crate) const DOTENV_PATH: &str = "DOTENV-PATH"; pub(crate) const DRY_RUN: &str = "DRY-RUN"; @@ -110,6 +113,12 @@ mod arg { pub(crate) const COLOR_NEVER: &str = "never"; pub(crate) const COLOR_VALUES: &[&str] = &[COLOR_AUTO, COLOR_ALWAYS, COLOR_NEVER]; + pub(crate) const COMMAND_COLOR_CYAN: &str = "cyan"; + pub(crate) const COMMAND_COLOR_PURPLE: &str = "purple"; + pub(crate) const COMMAND_COLOR_NONE: &str = "none"; + pub(crate) const COMMAND_COLOR_VALUES: &[&str] = + &[COMMAND_COLOR_NONE, COMMAND_COLOR_CYAN, COMMAND_COLOR_PURPLE]; + pub(crate) const DUMP_FORMAT_JSON: &str = "json"; pub(crate) const DUMP_FORMAT_JUST: &str = "just"; pub(crate) const DUMP_FORMAT_VALUES: &[&str] = &[DUMP_FORMAT_JUST, DUMP_FORMAT_JSON]; @@ -136,11 +145,19 @@ impl Config { ) .arg( Arg::with_name(arg::COLOR) - .long("color") + .long("color") + .takes_value(true) + .possible_values(arg::COLOR_VALUES) + .default_value(arg::COLOR_AUTO) + .help("Print colorful output"), + ) + .arg( + Arg::with_name(arg::COMMAND_COLOR) + .long("command-color") .takes_value(true) - .possible_values(arg::COLOR_VALUES) - .default_value(arg::COLOR_AUTO) - .help("Print colorful output"), + .possible_values(arg::COMMAND_COLOR_VALUES) + .default_value(arg::COMMAND_COLOR_NONE) + .help("Color to use when echoing recipe lines"), ) .arg( Arg::with_name(arg::DRY_RUN) @@ -396,6 +413,23 @@ impl Config { } } + fn command_color_from_matches(matches: &ArgMatches) -> ConfigResult> { + let value = matches + .value_of(arg::COMMAND_COLOR) + .ok_or_else(|| ConfigError::Internal { + message: "`--command_color` had no value".to_string(), + })?; + + match value { + arg::COMMAND_COLOR_NONE => Ok(None), + arg::COMMAND_COLOR_CYAN => Ok(Some(Colour::Cyan)), + arg::COMMAND_COLOR_PURPLE => Ok(Some(Colour::Purple)), + _ => Err(ConfigError::Internal { + message: format!("Invalid argument `{value}` to --command_color."), + }), + } + } + fn dump_format_from_matches(matches: &ArgMatches) -> ConfigResult { let value = matches .value_of(arg::DUMP_FORMAT) @@ -422,6 +456,7 @@ impl Config { }; let color = Self::color_from_matches(matches)?; + let command_color = Self::command_color_from_matches(matches)?; let set_count = matches.occurrences_of(arg::SET); let mut overrides = BTreeMap::new(); @@ -588,6 +623,7 @@ impl Config { .unwrap_or(" ") .to_owned(), color, + command_color, invocation_directory, search_config, shell_args, diff --git a/src/recipe.rs b/src/recipe.rs index aa1c487a79..c1fa22f306 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -182,7 +182,7 @@ impl<'src, D> Recipe<'src, D> { || !((quiet_command ^ self.quiet) || config.verbosity.quiet()) { let color = if config.highlight { - config.color.command() + config.color.command(config.command_color) } else { config.color }; diff --git a/tests/command.rs b/tests/command.rs index 0529958a7e..fbb5029894 100644 --- a/tests/command.rs +++ b/tests/command.rs @@ -31,7 +31,7 @@ test! { error: The argument '--command ' requires a value but none was supplied USAGE: - just{EXE_SUFFIX} --color --dump-format --shell \ + just{EXE_SUFFIX} --color --command-color --dump-format --shell \ <--changelog|--choose|--command |--completions |--dump|--edit|\ --evaluate|--fmt|--init|--list|--show |--summary|--variables> From 32e8bcab12737926dce040d0e4c84e6b7e705bb0 Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Sat, 9 Sep 2023 12:53:29 -0400 Subject: [PATCH 02/18] WIP draft command color --- src/color.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/color.rs b/src/color.rs index 7eedc4a795..39d1fe3277 100644 --- a/src/color.rs +++ b/src/color.rs @@ -78,10 +78,10 @@ impl Color { } pub(crate) fn command(self, foreground_color: Option) -> Self { - let new_style = if let Some(fg) = foreground_color { - Style::new().fg(fg).bold() - } else { - Style::new().bold() + let new_style = Style { + foreground: foreground_color, + is_bold: true, + ..Style::default() }; self.restyle(new_style) } @@ -91,7 +91,7 @@ impl Color { } pub(crate) fn message(self) -> Self { - self.restyle(Style::new().fg(Purple).bold()) + self.restyle(Style::new().bold()) } pub(crate) fn annotation(self) -> Self { From 28ae41c24c3364706e22c21e0540143a5d8727f5 Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Sat, 9 Sep 2023 12:58:11 -0400 Subject: [PATCH 03/18] format --- src/config.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/config.rs b/src/config.rs index 118c1a1907..cbc68406e6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -145,11 +145,11 @@ impl Config { ) .arg( Arg::with_name(arg::COLOR) - .long("color") - .takes_value(true) - .possible_values(arg::COLOR_VALUES) - .default_value(arg::COLOR_AUTO) - .help("Print colorful output"), + .long("color") + .takes_value(true) + .possible_values(arg::COLOR_VALUES) + .default_value(arg::COLOR_AUTO) + .help("Print colorful output"), ) .arg( Arg::with_name(arg::COMMAND_COLOR) From 6a01c2568b1a15d2a00c165d3981bbc989900a23 Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Sat, 9 Sep 2023 12:59:20 -0400 Subject: [PATCH 04/18] typo --- src/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index cbc68406e6..efa06387fe 100644 --- a/src/config.rs +++ b/src/config.rs @@ -417,7 +417,7 @@ impl Config { let value = matches .value_of(arg::COMMAND_COLOR) .ok_or_else(|| ConfigError::Internal { - message: "`--command_color` had no value".to_string(), + message: "`--command-color` had no value".to_string(), })?; match value { @@ -425,7 +425,7 @@ impl Config { arg::COMMAND_COLOR_CYAN => Ok(Some(Colour::Cyan)), arg::COMMAND_COLOR_PURPLE => Ok(Some(Colour::Purple)), _ => Err(ConfigError::Internal { - message: format!("Invalid argument `{value}` to --command_color."), + message: format!("Invalid argument `{value}` to --command-color."), }), } } From cb4c02d638a2eb601d0bbc12fdd2137177658250 Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:46:49 -0400 Subject: [PATCH 05/18] Update src/color.rs Co-authored-by: Casey Rodarmor --- src/color.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/color.rs b/src/color.rs index 39d1fe3277..a9e06fcc74 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,4 +1,3 @@ -use ansi_term::Colour; use { super::*, ansi_term::{ANSIGenericString, Color::*, Prefix, Style, Suffix}, From 74adcbf9e47cff35ff87e93de9c7c6c851ade5ba Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:47:10 -0400 Subject: [PATCH 06/18] Update src/color.rs Co-authored-by: Casey Rodarmor --- src/color.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/color.rs b/src/color.rs index a9e06fcc74..56670acc4b 100644 --- a/src/color.rs +++ b/src/color.rs @@ -76,13 +76,12 @@ impl Color { self.restyle(Style::new().fg(Cyan).bold()) } - pub(crate) fn command(self, foreground_color: Option) -> Self { - let new_style = Style { - foreground: foreground_color, + pub(crate) fn command(self, foreground: Option) -> Self { + self.restyle(Style { + foreground, is_bold: true, ..Style::default() - }; - self.restyle(new_style) + }) } pub(crate) fn parameter(self) -> Self { From d4f4898ed635138a72557bb12867ccd309ad94fc Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:47:16 -0400 Subject: [PATCH 07/18] Update src/config.rs Co-authored-by: Casey Rodarmor --- src/config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index efa06387fe..d048137e79 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,3 @@ -use ansi_term::Colour; use { super::*, clap::{App, AppSettings, Arg, ArgGroup, ArgMatches, ArgSettings}, From f7273691e0a3b7f950f37f76c3bdf035943d8138 Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:47:24 -0400 Subject: [PATCH 08/18] Update src/config.rs Co-authored-by: Casey Rodarmor --- src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index d048137e79..c24c5ee2a3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -15,7 +15,7 @@ pub(crate) const CHOOSE_HELP: &str = "Select one or more recipes to run using a pub(crate) struct Config { pub(crate) check: bool, pub(crate) color: Color, - pub(crate) command_color: Option, + pub(crate) command_color: Option, pub(crate) dotenv_filename: Option, pub(crate) dotenv_path: Option, pub(crate) dry_run: bool, From 48e86c5b66048ba4da89b9db6b4502d3f0c3e353 Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:47:29 -0400 Subject: [PATCH 09/18] Update src/config.rs Co-authored-by: Casey Rodarmor --- src/config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index c24c5ee2a3..d5a9f971f2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -114,7 +114,6 @@ mod arg { pub(crate) const COMMAND_COLOR_CYAN: &str = "cyan"; pub(crate) const COMMAND_COLOR_PURPLE: &str = "purple"; - pub(crate) const COMMAND_COLOR_NONE: &str = "none"; pub(crate) const COMMAND_COLOR_VALUES: &[&str] = &[COMMAND_COLOR_NONE, COMMAND_COLOR_CYAN, COMMAND_COLOR_PURPLE]; From 14941b6898750b010ae6f9b90d564fe84043bf87 Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:47:37 -0400 Subject: [PATCH 10/18] Update src/config.rs Co-authored-by: Casey Rodarmor --- src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index d5a9f971f2..788086f929 100644 --- a/src/config.rs +++ b/src/config.rs @@ -115,7 +115,7 @@ mod arg { pub(crate) const COMMAND_COLOR_CYAN: &str = "cyan"; pub(crate) const COMMAND_COLOR_PURPLE: &str = "purple"; pub(crate) const COMMAND_COLOR_VALUES: &[&str] = - &[COMMAND_COLOR_NONE, COMMAND_COLOR_CYAN, COMMAND_COLOR_PURPLE]; + &[COMMAND_COLOR_CYAN, COMMAND_COLOR_PURPLE]; pub(crate) const DUMP_FORMAT_JSON: &str = "json"; pub(crate) const DUMP_FORMAT_JUST: &str = "just"; From 548c9228369b477a94ee23809fd407d6b9de6ccb Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:47:44 -0400 Subject: [PATCH 11/18] Update src/config.rs Co-authored-by: Casey Rodarmor --- src/config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 788086f929..aeb03c720d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -154,7 +154,6 @@ impl Config { .long("command-color") .takes_value(true) .possible_values(arg::COMMAND_COLOR_VALUES) - .default_value(arg::COMMAND_COLOR_NONE) .help("Color to use when echoing recipe lines"), ) .arg( From 35c6c8a068bf8db54b35ee8482d3a4065cc1fbb5 Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:47:53 -0400 Subject: [PATCH 12/18] Update src/config.rs Co-authored-by: Casey Rodarmor --- src/config.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/config.rs b/src/config.rs index aeb03c720d..50629a9b60 100644 --- a/src/config.rs +++ b/src/config.rs @@ -411,16 +411,9 @@ impl Config { } fn command_color_from_matches(matches: &ArgMatches) -> ConfigResult> { - let value = matches - .value_of(arg::COMMAND_COLOR) - .ok_or_else(|| ConfigError::Internal { - message: "`--command-color` had no value".to_string(), - })?; - - match value { - arg::COMMAND_COLOR_NONE => Ok(None), - arg::COMMAND_COLOR_CYAN => Ok(Some(Colour::Cyan)), - arg::COMMAND_COLOR_PURPLE => Ok(Some(Colour::Purple)), + match matches.value_of(arg::COMMAND_COLOR)? { + arg::COMMAND_COLOR_CYAN => Ok(Some(ansi_term::Color::Cyan)), + arg::COMMAND_COLOR_PURPLE => Ok(Some(ansi_term::Color::Purple)), _ => Err(ConfigError::Internal { message: format!("Invalid argument `{value}` to --command-color."), }), From 04161ec6700224d49202fd8883bd7394d81ebab5 Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Tue, 10 Oct 2023 18:26:42 -0400 Subject: [PATCH 13/18] update gitignore to include intellij folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 17ed309524..e6c81f9f4f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +.idea /.vagrant /README.html /book/en/build From 49e24212ce283d524d9566a8b2040f297cdf028d Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Tue, 10 Oct 2023 18:26:51 -0400 Subject: [PATCH 14/18] adding all colors --- src/config.rs | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/config.rs b/src/config.rs index 50629a9b60..7efff84d96 100644 --- a/src/config.rs +++ b/src/config.rs @@ -112,10 +112,22 @@ mod arg { pub(crate) const COLOR_NEVER: &str = "never"; pub(crate) const COLOR_VALUES: &[&str] = &[COLOR_AUTO, COLOR_ALWAYS, COLOR_NEVER]; - pub(crate) const COMMAND_COLOR_CYAN: &str = "cyan"; + pub(crate) const COMMAND_COLOR_BLACK: &str = "black"; + pub(crate) const COMMAND_COLOR_RED: &str = "red"; + pub(crate) const COMMAND_COLOR_GREEN: &str = "green"; + pub(crate) const COMMAND_COLOR_YELLOW: &str = "yellow"; + pub(crate) const COMMAND_COLOR_BLUE: &str = "blue"; pub(crate) const COMMAND_COLOR_PURPLE: &str = "purple"; - pub(crate) const COMMAND_COLOR_VALUES: &[&str] = - &[COMMAND_COLOR_CYAN, COMMAND_COLOR_PURPLE]; + pub(crate) const COMMAND_COLOR_CYAN: &str = "cyan"; + pub(crate) const COMMAND_COLOR_VALUES: &[&str] = &[ + COMMAND_COLOR_BLACK, + COMMAND_COLOR_RED, + COMMAND_COLOR_GREEN, + COMMAND_COLOR_YELLOW, + COMMAND_COLOR_BLUE, + COMMAND_COLOR_PURPLE, + COMMAND_COLOR_CYAN, + ]; pub(crate) const DUMP_FORMAT_JSON: &str = "json"; pub(crate) const DUMP_FORMAT_JUST: &str = "just"; @@ -410,13 +422,22 @@ impl Config { } } - fn command_color_from_matches(matches: &ArgMatches) -> ConfigResult> { - match matches.value_of(arg::COMMAND_COLOR)? { - arg::COMMAND_COLOR_CYAN => Ok(Some(ansi_term::Color::Cyan)), - arg::COMMAND_COLOR_PURPLE => Ok(Some(ansi_term::Color::Purple)), - _ => Err(ConfigError::Internal { - message: format!("Invalid argument `{value}` to --command-color."), - }), + fn command_color_from_matches(matches: &ArgMatches) -> ConfigResult> { + if let Some(value) = matches.value_of(arg::COMMAND_COLOR) { + match value { + arg::COMMAND_COLOR_BLACK => Ok(Some(ansi_term::Color::Black)), + arg::COMMAND_COLOR_RED => Ok(Some(ansi_term::Color::Red)), + arg::COMMAND_COLOR_GREEN => Ok(Some(ansi_term::Color::Green)), + arg::COMMAND_COLOR_YELLOW => Ok(Some(ansi_term::Color::Yellow)), + arg::COMMAND_COLOR_BLUE => Ok(Some(ansi_term::Color::Blue)), + arg::COMMAND_COLOR_PURPLE => Ok(Some(ansi_term::Color::Purple)), + arg::COMMAND_COLOR_CYAN => Ok(Some(ansi_term::Color::Cyan)), + value => Err(ConfigError::Internal { + message: format!("Invalid argument `{value}` to --command-color."), + }), + } + } else { + Ok(None) } } From 18403a008483b498bd496ba0e2b5f1c111a19660 Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Tue, 10 Oct 2023 18:26:56 -0400 Subject: [PATCH 15/18] updating tests --- tests/command.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/command.rs b/tests/command.rs index fbb5029894..c1c9473ef8 100644 --- a/tests/command.rs +++ b/tests/command.rs @@ -20,6 +20,18 @@ test! { stdout: "foo", } +test! { + name: command_color, + justfile: " + x: + echo XYZ + ", + args: ("--color", "always", "--command-color", "cyan"), + stdout: "XYZ\n", + stderr: "\u{1b}[1;36mecho XYZ\u{1b}[0m\n", + status: EXIT_SUCCESS, +} + test! { name: no_binary, justfile: " @@ -31,7 +43,7 @@ test! { error: The argument '--command ' requires a value but none was supplied USAGE: - just{EXE_SUFFIX} --color --command-color --dump-format --shell \ + just{EXE_SUFFIX} --color --dump-format --shell \ <--changelog|--choose|--command |--completions |--dump|--edit|\ --evaluate|--fmt|--init|--list|--show |--summary|--variables> From 94abea1e95754a37db310db472a829b234092f0c Mon Sep 17 00:00:00 2001 From: N <47500890+avi-cenna@users.noreply.github.com> Date: Tue, 10 Oct 2023 18:40:04 -0400 Subject: [PATCH 16/18] update completions --- completions/just.bash | 6 +++++- completions/just.elvish | 1 + completions/just.fish | 1 + completions/just.powershell | 1 + completions/just.zsh | 1 + 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/completions/just.bash b/completions/just.bash index 9c7945b22e..ffb85a2131 100644 --- a/completions/just.bash +++ b/completions/just.bash @@ -20,7 +20,7 @@ _just() { case "${cmd}" in just) - opts=" -n -q -u -v -e -l -h -V -f -d -c -s --check --dry-run --highlight --no-dotenv --no-highlight --quiet --shell-command --clear-shell-args --unsorted --unstable --verbose --changelog --choose --dump --edit --evaluate --fmt --init --list --summary --variables --help --version --chooser --color --dump-format --list-heading --list-prefix --justfile --set --shell --shell-arg --working-directory --command --completions --show --dotenv-filename --dotenv-path ... " + opts=" -n -q -u -v -e -l -h -V -f -d -c -s --check --dry-run --highlight --no-dotenv --no-highlight --quiet --shell-command --clear-shell-args --unsorted --unstable --verbose --changelog --choose --dump --edit --evaluate --fmt --init --list --summary --variables --help --version --chooser --color --command-color --dump-format --list-heading --list-prefix --justfile --set --shell --shell-arg --working-directory --command --completions --show --dotenv-filename --dotenv-path ... " if [[ ${cur} == -* ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -48,6 +48,10 @@ _just() { COMPREPLY=($(compgen -W "auto always never" -- "${cur}")) return 0 ;; + --command-color) + COMPREPLY=($(compgen -W "black red green yellow blue purple cyan" -- "${cur}")) + return 0 + ;; --dump-format) COMPREPLY=($(compgen -W "just json" -- "${cur}")) return 0 diff --git a/completions/just.elvish b/completions/just.elvish index 1a208afccd..94da8e9ef9 100644 --- a/completions/just.elvish +++ b/completions/just.elvish @@ -16,6 +16,7 @@ edit:completion:arg-completer[just] = [@words]{ &'just'= { cand --chooser 'Override binary invoked by `--choose`' cand --color 'Print colorful output' + cand --command-color 'Color to use when echoing recipe lines' cand --dump-format 'Dump justfile as ' cand --list-heading 'Print before list' cand --list-prefix 'Print before each list item' diff --git a/completions/just.fish b/completions/just.fish index 43d417741b..83f48862f7 100644 --- a/completions/just.fish +++ b/completions/just.fish @@ -11,6 +11,7 @@ complete -c just -a '(__fish_just_complete_recipes)' # autogenerated completions complete -c just -n "__fish_use_subcommand" -l chooser -d 'Override binary invoked by `--choose`' complete -c just -n "__fish_use_subcommand" -l color -d 'Print colorful output' -r -f -a "auto always never" +complete -c just -n "__fish_use_subcommand" -l command-color -d 'Color to use when echoing recipe lines' -r -f -a "black red green yellow blue purple cyan" complete -c just -n "__fish_use_subcommand" -l dump-format -d 'Dump justfile as ' -r -f -a "just json" complete -c just -n "__fish_use_subcommand" -l list-heading -d 'Print before list' complete -c just -n "__fish_use_subcommand" -l list-prefix -d 'Print before each list item' diff --git a/completions/just.powershell b/completions/just.powershell index 1ed04d306a..50a214cd13 100644 --- a/completions/just.powershell +++ b/completions/just.powershell @@ -21,6 +21,7 @@ Register-ArgumentCompleter -Native -CommandName 'just' -ScriptBlock { 'just' { [CompletionResult]::new('--chooser', 'chooser', [CompletionResultType]::ParameterName, 'Override binary invoked by `--choose`') [CompletionResult]::new('--color', 'color', [CompletionResultType]::ParameterName, 'Print colorful output') + [CompletionResult]::new('--command-color', 'command-color', [CompletionResultType]::ParameterName, 'Color to use when echoing recipe lines') [CompletionResult]::new('--dump-format', 'dump-format', [CompletionResultType]::ParameterName, 'Dump justfile as ') [CompletionResult]::new('--list-heading', 'list-heading', [CompletionResultType]::ParameterName, 'Print before list') [CompletionResult]::new('--list-prefix', 'list-prefix', [CompletionResultType]::ParameterName, 'Print before each list item') diff --git a/completions/just.zsh b/completions/just.zsh index a3aff350a2..c214c206e9 100644 --- a/completions/just.zsh +++ b/completions/just.zsh @@ -17,6 +17,7 @@ _just() { local common=( '--chooser=[Override binary invoked by `--choose`]' \ '--color=[Print colorful output]: :(auto always never)' \ +'--command-color=[Color to use when echoing recipe lines]: :(black red green yellow blue purple cyan)' \ '--dump-format=[Dump justfile as ]: :(just json)' \ '--list-heading=[Print before list]' \ '--list-prefix=[Print before each list item]' \ From 36a9d4edf51581c6f11807128f0dc9ab169700f0 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Tue, 10 Oct 2023 17:00:56 -0700 Subject: [PATCH 17/18] Sort color values and reword help string --- src/config.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/config.rs b/src/config.rs index d051006e3e..1e6e86d117 100644 --- a/src/config.rs +++ b/src/config.rs @@ -113,20 +113,20 @@ mod arg { pub(crate) const COLOR_VALUES: &[&str] = &[COLOR_AUTO, COLOR_ALWAYS, COLOR_NEVER]; pub(crate) const COMMAND_COLOR_BLACK: &str = "black"; - pub(crate) const COMMAND_COLOR_RED: &str = "red"; - pub(crate) const COMMAND_COLOR_GREEN: &str = "green"; - pub(crate) const COMMAND_COLOR_YELLOW: &str = "yellow"; pub(crate) const COMMAND_COLOR_BLUE: &str = "blue"; - pub(crate) const COMMAND_COLOR_PURPLE: &str = "purple"; pub(crate) const COMMAND_COLOR_CYAN: &str = "cyan"; + pub(crate) const COMMAND_COLOR_GREEN: &str = "green"; + pub(crate) const COMMAND_COLOR_PURPLE: &str = "purple"; + pub(crate) const COMMAND_COLOR_RED: &str = "red"; + pub(crate) const COMMAND_COLOR_YELLOW: &str = "yellow"; pub(crate) const COMMAND_COLOR_VALUES: &[&str] = &[ COMMAND_COLOR_BLACK, - COMMAND_COLOR_RED, - COMMAND_COLOR_GREEN, - COMMAND_COLOR_YELLOW, COMMAND_COLOR_BLUE, - COMMAND_COLOR_PURPLE, COMMAND_COLOR_CYAN, + COMMAND_COLOR_GREEN, + COMMAND_COLOR_PURPLE, + COMMAND_COLOR_RED, + COMMAND_COLOR_YELLOW, ]; pub(crate) const DUMP_FORMAT_JSON: &str = "json"; @@ -166,7 +166,7 @@ impl Config { .long("command-color") .takes_value(true) .possible_values(arg::COMMAND_COLOR_VALUES) - .help("Color to use when echoing recipe lines"), + .help("Echo recipe lines in "), ) .arg( Arg::with_name(arg::DRY_RUN) @@ -426,12 +426,12 @@ impl Config { if let Some(value) = matches.value_of(arg::COMMAND_COLOR) { match value { arg::COMMAND_COLOR_BLACK => Ok(Some(ansi_term::Color::Black)), - arg::COMMAND_COLOR_RED => Ok(Some(ansi_term::Color::Red)), - arg::COMMAND_COLOR_GREEN => Ok(Some(ansi_term::Color::Green)), - arg::COMMAND_COLOR_YELLOW => Ok(Some(ansi_term::Color::Yellow)), arg::COMMAND_COLOR_BLUE => Ok(Some(ansi_term::Color::Blue)), - arg::COMMAND_COLOR_PURPLE => Ok(Some(ansi_term::Color::Purple)), arg::COMMAND_COLOR_CYAN => Ok(Some(ansi_term::Color::Cyan)), + arg::COMMAND_COLOR_GREEN => Ok(Some(ansi_term::Color::Green)), + arg::COMMAND_COLOR_PURPLE => Ok(Some(ansi_term::Color::Purple)), + arg::COMMAND_COLOR_RED => Ok(Some(ansi_term::Color::Red)), + arg::COMMAND_COLOR_YELLOW => Ok(Some(ansi_term::Color::Yellow)), value => Err(ConfigError::Internal { message: format!("Invalid argument `{value}` to --command-color."), }), From b6e30969940861964e8f9b568bfb617c5895eeed Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Tue, 10 Oct 2023 17:01:42 -0700 Subject: [PATCH 18/18] Update completions --- completions/just.bash | 2 +- completions/just.elvish | 2 +- completions/just.fish | 2 +- completions/just.powershell | 2 +- completions/just.zsh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/completions/just.bash b/completions/just.bash index ffb85a2131..99d7fdb716 100644 --- a/completions/just.bash +++ b/completions/just.bash @@ -49,7 +49,7 @@ _just() { return 0 ;; --command-color) - COMPREPLY=($(compgen -W "black red green yellow blue purple cyan" -- "${cur}")) + COMPREPLY=($(compgen -W "black blue cyan green purple red yellow" -- "${cur}")) return 0 ;; --dump-format) diff --git a/completions/just.elvish b/completions/just.elvish index 94da8e9ef9..1b3be811f1 100644 --- a/completions/just.elvish +++ b/completions/just.elvish @@ -16,7 +16,7 @@ edit:completion:arg-completer[just] = [@words]{ &'just'= { cand --chooser 'Override binary invoked by `--choose`' cand --color 'Print colorful output' - cand --command-color 'Color to use when echoing recipe lines' + cand --command-color 'Echo recipe lines in ' cand --dump-format 'Dump justfile as ' cand --list-heading 'Print before list' cand --list-prefix 'Print before each list item' diff --git a/completions/just.fish b/completions/just.fish index 83f48862f7..0771de0135 100644 --- a/completions/just.fish +++ b/completions/just.fish @@ -11,7 +11,7 @@ complete -c just -a '(__fish_just_complete_recipes)' # autogenerated completions complete -c just -n "__fish_use_subcommand" -l chooser -d 'Override binary invoked by `--choose`' complete -c just -n "__fish_use_subcommand" -l color -d 'Print colorful output' -r -f -a "auto always never" -complete -c just -n "__fish_use_subcommand" -l command-color -d 'Color to use when echoing recipe lines' -r -f -a "black red green yellow blue purple cyan" +complete -c just -n "__fish_use_subcommand" -l command-color -d 'Echo recipe lines in ' -r -f -a "black blue cyan green purple red yellow" complete -c just -n "__fish_use_subcommand" -l dump-format -d 'Dump justfile as ' -r -f -a "just json" complete -c just -n "__fish_use_subcommand" -l list-heading -d 'Print before list' complete -c just -n "__fish_use_subcommand" -l list-prefix -d 'Print before each list item' diff --git a/completions/just.powershell b/completions/just.powershell index 50a214cd13..0842dc8c78 100644 --- a/completions/just.powershell +++ b/completions/just.powershell @@ -21,7 +21,7 @@ Register-ArgumentCompleter -Native -CommandName 'just' -ScriptBlock { 'just' { [CompletionResult]::new('--chooser', 'chooser', [CompletionResultType]::ParameterName, 'Override binary invoked by `--choose`') [CompletionResult]::new('--color', 'color', [CompletionResultType]::ParameterName, 'Print colorful output') - [CompletionResult]::new('--command-color', 'command-color', [CompletionResultType]::ParameterName, 'Color to use when echoing recipe lines') + [CompletionResult]::new('--command-color', 'command-color', [CompletionResultType]::ParameterName, 'Echo recipe lines in ') [CompletionResult]::new('--dump-format', 'dump-format', [CompletionResultType]::ParameterName, 'Dump justfile as ') [CompletionResult]::new('--list-heading', 'list-heading', [CompletionResultType]::ParameterName, 'Print before list') [CompletionResult]::new('--list-prefix', 'list-prefix', [CompletionResultType]::ParameterName, 'Print before each list item') diff --git a/completions/just.zsh b/completions/just.zsh index c214c206e9..4ddfa867ca 100644 --- a/completions/just.zsh +++ b/completions/just.zsh @@ -17,7 +17,7 @@ _just() { local common=( '--chooser=[Override binary invoked by `--choose`]' \ '--color=[Print colorful output]: :(auto always never)' \ -'--command-color=[Color to use when echoing recipe lines]: :(black red green yellow blue purple cyan)' \ +'--command-color=[Echo recipe lines in ]: :(black blue cyan green purple red yellow)' \ '--dump-format=[Dump justfile as ]: :(just json)' \ '--list-heading=[Print before list]' \ '--list-prefix=[Print before each list item]' \