From 01c030d5b50f00afeaaf0f4f0f928b23fdbd0fe3 Mon Sep 17 00:00:00 2001 From: David Harrigan Date: Tue, 24 Oct 2023 07:46:52 +0100 Subject: [PATCH] Updates based upon PR feedback. Rename `quiet-recipes` to quiet. Rename `no-quiet-recipes` to `no-quiet`. -=david=- --- GRAMMAR.md | 2 +- README.md | 30 +++++++++++++++--------------- src/attribute.rs | 6 +++--- src/keyword.rs | 2 +- src/node.rs | 2 +- src/parser.rs | 20 ++++++++++---------- src/recipe.rs | 10 +++++----- src/setting.rs | 4 ++-- src/settings.rs | 6 +++--- tests/json.rs | 34 +++++++++++++++++----------------- 10 files changed, 58 insertions(+), 58 deletions(-) diff --git a/GRAMMAR.md b/GRAMMAR.md index a9f4ef0e7a..dbe7e88d91 100644 --- a/GRAMMAR.md +++ b/GRAMMAR.md @@ -67,7 +67,7 @@ setting : 'set' 'allow-duplicate-recipes' boolean? | 'set' 'fallback' boolean? | 'set' 'ignore-comments' boolean? | 'set' 'positional-arguments' boolean? - | 'set' 'quiet-recipes' boolean? + | 'set' 'quiet' boolean? | 'set' 'shell' ':=' '[' string (',' string)* ','? ']' | 'set' 'tempdir ':=' string | 'set' 'windows-powershell' boolean? diff --git a/README.md b/README.md index 0e7cb65c0e..ac89a0920c 100644 --- a/README.md +++ b/README.md @@ -1248,16 +1248,16 @@ These functions can fail, for example if a path does not have an extension, whic Recipes may be annotated with attributes that change their behavior. -| Name | Description | -| ----------------------------------- | ----------------------------------------------- | -| `[no-cd]`1.9.0 | Don't change directory before executing recipe. | -| `[no-exit-message]`1.7.0 | Don't print an error message if recipe fails. | -| `[no-quiet-recipe]`? | Override globally quiet recipe and always echo out the recipe | -| `[linux]`1.8.0 | Enable recipe on Linux. | -| `[macos]`1.8.0 | Enable recipe on MacOS. | -| `[unix]`1.8.0 | Enable recipe on Unixes. (Includes MacOS). | -| `[windows]`1.8.0 | Enable recipe on Windows. | -| `[private]`1.10.0 | See [Private Recipes](#private-recipes). | +| Name | Description | +| ----------------------------------- | ----------------------------------------------- | +| `[no-cd]`1.9.0 | Don't change directory before executing recipe. | +| `[no-exit-message]`1.7.0 | Don't print an error message if recipe fails. | +| `[no-quiet]`? | Override globally quiet recipes and always echo out the recipe | +| `[linux]`1.8.0 | Enable recipe on Linux. | +| `[macos]`1.8.0 | Enable recipe on MacOS. | +| `[unix]`1.8.0 | Enable recipe on Unixes. (Includes MacOS). | +| `[windows]`1.8.0 | Enable recipe on Windows. | +| `[private]`1.10.0 | See [Private Recipes](#private-recipes). | A recipe can have multiple attributes, either on multiple lines: @@ -2221,10 +2221,10 @@ goodbye ``` In addition, an entire Justfile can be marked as being globally quiet by -setting `set quiet-recipes` in the Justfile. For example: +setting `set quiet` in the Justfile. For example: ```just -set quiet-recipes +set quiet foo: echo "This is quiet" @@ -2233,16 +2233,16 @@ foo: echo "This is also quiet" ``` -If the recipe has the attribute of `[no-quiet-recipe]`, then the setting is +If the recipe has the attribute of `[no-quiet]`, then the setting is ignored: For example: ```just -set quiet-recipes +set quiet foo: echo "This is quiet" -[no-quiet-recipe] +[no-quiet] foo2: echo "This is not quiet" ``` diff --git a/src/attribute.rs b/src/attribute.rs index 39d80b61ba..fbd17509c1 100644 --- a/src/attribute.rs +++ b/src/attribute.rs @@ -12,7 +12,7 @@ pub(crate) enum Attribute { NoCd, NoExitMessage, Private, - NoQuietRecipe, + NoQuiet, Unix, Windows, } @@ -37,7 +37,7 @@ mod tests { } #[test] - fn no_quiet_recipe_to_str() { - assert_eq!(Attribute::NoQuietRecipe.to_str(), "no-quiet-recipe"); + fn no_quiet_to_str() { + assert_eq!(Attribute::NoQuiet.to_str(), "no-quiet"); } } diff --git a/src/keyword.rs b/src/keyword.rs index 89767e5f72..b09868d304 100644 --- a/src/keyword.rs +++ b/src/keyword.rs @@ -16,7 +16,7 @@ pub(crate) enum Keyword { IgnoreComments, Import, PositionalArguments, - QuietRecipes, + Quiet, Set, Shell, Tempdir, diff --git a/src/node.rs b/src/node.rs index 4dc6ffc97d..69a2b3f87b 100644 --- a/src/node.rs +++ b/src/node.rs @@ -239,7 +239,7 @@ impl<'src> Node<'src> for Set<'src> { | Setting::Export(value) | Setting::Fallback(value) | Setting::PositionalArguments(value) - | Setting::QuietRecipes(value) + | Setting::Quiet(value) | Setting::WindowsPowerShell(value) | Setting::IgnoreComments(value) => { set.push_mut(value.to_string()); diff --git a/src/parser.rs b/src/parser.rs index d7ec0f8c3c..caaed58551 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -802,7 +802,7 @@ impl<'tokens, 'src> Parser<'tokens, 'src> { Keyword::Fallback => Some(Setting::Fallback(self.parse_set_bool()?)), Keyword::IgnoreComments => Some(Setting::IgnoreComments(self.parse_set_bool()?)), Keyword::PositionalArguments => Some(Setting::PositionalArguments(self.parse_set_bool()?)), - Keyword::QuietRecipes => Some(Setting::QuietRecipes(self.parse_set_bool()?)), + Keyword::Quiet => Some(Setting::Quiet(self.parse_set_bool()?)), Keyword::WindowsPowershell => Some(Setting::WindowsPowerShell(self.parse_set_bool()?)), _ => None, }; @@ -1866,21 +1866,21 @@ mod tests { } test! { - name: set_quiet_recipes_implicit, - text: "set quiet-recipes", - tree: (justfile (set quiet_recipes true)), + name: set_quiet_implicit, + text: "set quiet", + tree: (justfile (set quiet true)), } test! { - name: set_quiet_recipes_true, - text: "set quiet-recipes := true", - tree: (justfile (set quiet_recipes true)), + name: set_quiet_true, + text: "set quiet := true", + tree: (justfile (set quiet true)), } test! { - name: set_quiet_recipes_false, - text: "set quiet-recipes := false", - tree: (justfile (set quiet_recipes false)), + name: set_quiet_false, + text: "set quiet := false", + tree: (justfile (set quiet false)), } test! { diff --git a/src/recipe.rs b/src/recipe.rs index 73215985a6..e8001fac37 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -103,8 +103,8 @@ impl<'src, D> Recipe<'src, D> { !self.attributes.contains(&Attribute::NoExitMessage) } - fn no_quiet_recipe(&self) -> bool { - !self.attributes.contains(&Attribute::NoQuietRecipe) + fn no_quiet(&self) -> bool { + !self.attributes.contains(&Attribute::NoQuiet) } pub(crate) fn run<'run>( @@ -155,7 +155,7 @@ impl<'src, D> Recipe<'src, D> { let mut evaluated = String::new(); let mut continued = false; - let quiet_command = self.no_quiet_recipe() && context.settings.quiet_recipes + let quiet_command = self.no_quiet() && context.settings.quiet || lines.peek().map_or(false, |line| line.is_quiet()); let infallible_command = lines.peek().map_or(false, |line| line.is_infallible()); @@ -186,7 +186,7 @@ impl<'src, D> Recipe<'src, D> { let mut command = evaluated.as_str(); - if quiet_command && !context.settings.quiet_recipes { + if quiet_command && !context.settings.quiet { command = &command[1..]; } @@ -201,7 +201,7 @@ impl<'src, D> Recipe<'src, D> { if config.dry_run || config.verbosity.loquacious() || !((quiet_command ^ self.quiet) - || (context.settings.quiet_recipes && self.no_quiet_recipe()) + || (context.settings.quiet && self.no_quiet()) || config.verbosity.quiet()) { let color = if config.highlight { diff --git a/src/setting.rs b/src/setting.rs index 329c4018c2..0256ff94c9 100644 --- a/src/setting.rs +++ b/src/setting.rs @@ -10,7 +10,7 @@ pub(crate) enum Setting<'src> { Fallback(bool), IgnoreComments(bool), PositionalArguments(bool), - QuietRecipes(bool), + Quiet(bool), Shell(Shell<'src>), Tempdir(String), WindowsPowerShell(bool), @@ -26,7 +26,7 @@ impl<'src> Display for Setting<'src> { | Setting::Fallback(value) | Setting::IgnoreComments(value) | Setting::PositionalArguments(value) - | Setting::QuietRecipes(value) + | Setting::Quiet(value) | Setting::WindowsPowerShell(value) => write!(f, "{value}"), Setting::Shell(shell) | Setting::WindowsShell(shell) => write!(f, "{shell}"), Setting::DotenvFilename(value) | Setting::DotenvPath(value) | Setting::Tempdir(value) => { diff --git a/src/settings.rs b/src/settings.rs index 0da64bbafc..0aa91b5387 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -16,7 +16,7 @@ pub(crate) struct Settings<'src> { pub(crate) fallback: bool, pub(crate) ignore_comments: bool, pub(crate) positional_arguments: bool, - pub(crate) quiet_recipes: bool, + pub(crate) quiet: bool, pub(crate) shell: Option>, pub(crate) tempdir: Option, pub(crate) windows_powershell: bool, @@ -53,8 +53,8 @@ impl<'src> Settings<'src> { Setting::PositionalArguments(positional_arguments) => { settings.positional_arguments = positional_arguments; } - Setting::QuietRecipes(quiet_recipes) => { - settings.quiet_recipes = quiet_recipes; + Setting::Quiet(quiet) => { + settings.quiet = quiet; } Setting::Shell(shell) => { settings.shell = Some(shell); diff --git a/tests/json.rs b/tests/json.rs index 2fe361693a..d49cdc486e 100644 --- a/tests/json.rs +++ b/tests/json.rs @@ -48,7 +48,7 @@ fn alias() { "export": false, "fallback": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir" : null, "ignore_comments": false, @@ -84,7 +84,7 @@ fn assignment() { "fallback": false, "ignore_comments": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir" : null, "windows_powershell": false, @@ -133,7 +133,7 @@ fn body() { "fallback": false, "ignore_comments": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir" : null, "windows_powershell": false, @@ -193,7 +193,7 @@ fn dependencies() { "fallback": false, "ignore_comments": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir" : null, "windows_powershell": false, @@ -290,7 +290,7 @@ fn dependency_argument() { "fallback": false, "ignore_comments": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir" : null, "windows_powershell": false, @@ -351,7 +351,7 @@ fn duplicate_recipes() { "fallback": false, "ignore_comments": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir" : null, "windows_powershell": false, @@ -393,7 +393,7 @@ fn doc_comment() { "fallback": false, "ignore_comments": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir" : null, "windows_powershell": false, @@ -422,7 +422,7 @@ fn empty_justfile() { "fallback": false, "ignore_comments": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir" : null, "windows_powershell": false, @@ -566,7 +566,7 @@ fn parameters() { "fallback": false, "ignore_comments": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir" : null, "windows_powershell": false, @@ -646,7 +646,7 @@ fn priors() { "fallback": false, "ignore_comments": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir" : null, "windows_powershell": false, @@ -688,7 +688,7 @@ fn private() { "fallback": false, "ignore_comments": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir" : null, "windows_powershell": false, @@ -730,7 +730,7 @@ fn quiet() { "fallback": false, "ignore_comments": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir" : null, "windows_powershell": false, @@ -751,7 +751,7 @@ fn settings() { set export set fallback set positional-arguments - set quiet-recipes + set quiet set ignore-comments set shell := ['a', 'b', 'c'] foo: @@ -784,7 +784,7 @@ fn settings() { "fallback": true, "ignore_comments": true, "positional_arguments": true, - "quiet_recipes": true, + "quiet": true, "shell": { "arguments": ["b", "c"], "command": "a", @@ -832,7 +832,7 @@ fn shebang() { "fallback": false, "ignore_comments": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir": null, "windows_powershell": false, @@ -874,7 +874,7 @@ fn simple() { "fallback": false, "ignore_comments": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir": null, "windows_powershell": false, @@ -918,7 +918,7 @@ fn attribute() { "export": false, "fallback": false, "positional_arguments": false, - "quiet_recipes": false, + "quiet": false, "shell": null, "tempdir" : null, "ignore_comments": false,