Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/issue 1698 global quiet #1704

Merged
merged 8 commits into from
Jan 12, 2024

Conversation

dharrigan
Copy link
Contributor

@dharrigan dharrigan commented Oct 17, 2023

Hi,

Here's a first pass at introducing quiet recipes. I'm happy to take unboard any thoughts you may have. Not quite sure about the name set quiet-recipes, but was struggling to come up with something better (maybe set globally-quiet?) :-)

Tests pass (with my additional ones added).

Thank you for your consideration.

#Fixes 1698

-=david=-

@casey
Copy link
Owner

casey commented Oct 22, 2023

Thanks for the PR!

Some thoughts:

  • Let's call the setting quiet, so you can do set quiet.
  • Let's call the attribute [noquiet]
  • We could also not have an attribute, and invert the meaning of @ if set quiet is used. So if you set quiet, you can do @recipe:, which would make that recipe not quiet. @` is a bit confusing though, so I'm not convinced either way on this.

@dharrigan
Copy link
Contributor Author

dharrigan commented Oct 22, 2023

Hi,

Thank you for your helpful feedback. I'll make the changes within the next few days :-)

With regards the inversion of the @. I thought about this and I decided on the principle of least surprise (for the user). They are used to @ to signify that the recipe (or line) should be quiet, so I didn't want to break that by introducing an inverted case. I would rather accrete changes than break expectations. I then thought that by introducing the attribute of [no-quiet-recipe] (now [noquiet]), they could then choose to make it explicit if they want an already demarked recipe of @ to become non-quiet when the global attribute is used.

So, no surprises was my thoughts behind that one :-)

-=david=-

@dharrigan
Copy link
Contributor Author

A question...

You've recommended the attribute to be renamed to noquiet. However, there is the precedent of no-exit-message, with a hyphen between the no and the action. Would it be better to be consisent and call the attribute no-quiet?

Thank you.

@casey
Copy link
Owner

casey commented Oct 24, 2023

Ah, yeah, good catch. In that case it should be no-quiet.

@dharrigan
Copy link
Contributor Author

Hi!

I was wondering if you have had a chance to consider to merge in this PR? Anything else I can do?

Thank you.

-=david=-

Copy link
Owner

@casey casey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I was slow getting to this! Check out my review comments.

README.md Outdated
@@ -188,10 +188,10 @@ You can also set the shell using command-line arguments. For example, to use Pow
<tr>
<td><a href="https://www.gentoo.org">Gentoo Linux</a></td>
<td><a href="https://wiki.gentoo.org/wiki/Portage">Portage</a></td>
<td><a href="https://github.com/gentoo-mirror/guru/tree/master/sys-devel/just">guru/sys-devel/just</a></td>
<td><a href="https://github.com/gentoo-mirror/dm9pZCAq/tree/master/sys-devel/just">dm9pZCAq/sys-devel/just</a></td>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there are some unrelated changes, and merge conflicts in README.md.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

README.md Outdated
| ----------------------------------- | ----------------------------------------------- |
| `[no-cd]`<sup>1.9.0</sup> | Don't change directory before executing recipe. |
| `[no-exit-message]`<sup>1.7.0</sup> | Don't print an error message if recipe fails. |
| `[no-quiet]`<sup>?</sup> | Override globally quiet recipes and always echo out the recipe |
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add [quiet].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't a [quiet] attribute, just [no-quiet] which overrides the set quiet if that's been set.

README.md Outdated
Comment on lines 2223 to 2224
In addition, an entire Justfile can be marked as being globally quiet by
setting `set quiet` in the Justfile. For example:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In addition, an entire Justfile can be marked as being globally quiet by
setting `set quiet` in the Justfile. For example:
All recipes in a Justfile can be made quiet with `set quiet`:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

README.md Outdated
Comment on lines 2236 to 2237
If the recipe has the attribute of `[no-quiet]`, then the setting is
ignored: For example:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If the recipe has the attribute of `[no-quiet]`, then the setting is
ignored: For example:
If a recipe has`[no-quiet]`, then the setting is ignored:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

README.md Outdated
@@ -2338,6 +2364,7 @@ import 'foo/bar.just'

a: b
@echo A

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/attribute.rs Outdated
@@ -31,7 +32,12 @@ mod tests {
use super::*;

#[test]
fn to_str() {
fn no_exit_message_to_str() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn no_exit_message_to_str() {
fn to_str() {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/attribute.rs Outdated
assert_eq!(Attribute::NoExitMessage.to_str(), "no-exit-message");
}

#[test]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this test. The other test is there just to make sure that we're serializing attribute names in kebab-case, but we don't need to test every variant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/recipe.rs Outdated
@@ -103,6 +103,10 @@ impl<'src, D> Recipe<'src, D> {
!self.attributes.contains(&Attribute::NoExitMessage)
}

fn no_quiet(&self) -> bool {
!self.attributes.contains(&Attribute::NoQuiet)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be inverted, i.e.:

Suggested change
!self.attributes.contains(&Attribute::NoQuiet)
self.attributes.contains(&Attribute::NoQuiet)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/recipe.rs Outdated
@@ -150,7 +154,10 @@ impl<'src, D> Recipe<'src, D> {
}
let mut evaluated = String::new();
let mut continued = false;
let quiet_command = lines.peek().map_or(false, |line| line.is_quiet());

let quiet_command = self.no_quiet() && context.settings.quiet
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to determine if we should strip a leading @ from the line, so we should only do so if it starts with an @:

Suggested change
let quiet_command = self.no_quiet() && context.settings.quiet
let quiet_line = lines.peek().map_or(false, |line| line.is_quiet());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/recipe.rs Outdated
Comment on lines 203 to 234
|| !((quiet_command ^ self.quiet)
|| (context.settings.quiet && self.no_quiet())
|| config.verbosity.quiet())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be something like:

Suggested change
|| !((quiet_command ^ self.quiet)
|| (context.settings.quiet && self.no_quiet())
|| config.verbosity.quiet())
|| !((quiet_line ^ self.quiet) || (context.settings.quiet && !self.no_quiet()) || config.verbosity.quiet())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@dharrigan dharrigan force-pushed the feat/issue-1698-global-quiet branch 5 times, most recently from a4b98cd to c2d4d29 Compare January 3, 2024 14:54
@dharrigan
Copy link
Contributor Author

Hi!

All changes asked for applied. When you can spare the time, have a looksee and see what you think :-)

Thank you.

-=david=-

Copy link
Owner

@casey casey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for letting this sit! This looks good, it just needs integration tests, which can go in tests/quiet.rs. The tests in that file are using the test! macro, which I try to avoid these days, so for examples of how to write tests, check out tests/modules.rs. In particular, all the interactions with the quiet setting, the noquiet attribute, quiet lines, and the @ prefix to both recipes in lines, should be tested.

This commit brings the concept of globally quiet recipes to the
Justfile. If the justfile has this setting:

set quiet

With this (implicitly true) setting, every recipe within the Justfile
will be quiet - unless the recipe has the (new) attribute of
[no-quiet].

closes casey#1698

-=david=-
@dharrigan
Copy link
Contributor Author

Hi,

Additional integration tests done. I hope this is looking better.

-=david=-

Copy link
Owner

@casey casey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@casey casey enabled auto-merge (squash) January 12, 2024 20:37
@casey casey merged commit 5bbc89b into casey:master Jan 12, 2024
5 checks passed
@casey
Copy link
Owner

casey commented Jan 12, 2024

Thanks for the PR! I tweaked it a little bit, simplifying the tests and removing an if statement that would never be executed.

This is easily the worst conditional I've ever seen, amazingly using ||, !, ^, and &&:

      if config.dry_run
        || config.verbosity.loquacious()
        || !((quiet_line ^ self.quiet)
          || (context.settings.quiet && !self.no_quiet())
          || config.verbosity.quiet())
      {

But so be it! Functionality for making things quiet or not quiet has just evolved organically over time, so I guess that's just how it is 😂

@dharrigan dharrigan deleted the feat/issue-1698-global-quiet branch January 13, 2024 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants