-
Notifications
You must be signed in to change notification settings - Fork 476
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
Add a confirm attribute for recipes #1723
Conversation
this in the recipe runner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added some comments, and I thought of something else: If a recipe doesn't run, any recipe in the current invocation which depends on that recipe should also not run.
src/attribute.rs
Outdated
@@ -13,6 +13,7 @@ pub(crate) enum Attribute { | |||
Private, | |||
Unix, | |||
Windows, | |||
Confirm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These enum variants should be sorted.
src/recipe.rs
Outdated
@@ -63,6 +63,16 @@ impl<'src, D> Recipe<'src, D> { | |||
self.name.line | |||
} | |||
|
|||
pub(crate) fn confirm(&self) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should be fallible, since read_line
can fail, so it should return RunResult<bool>
Corrected format Co-authored-by: Casey Rodarmor <[email protected]>
Removed extraneous whitespace Co-authored-by: Casey Rodarmor <[email protected]>
Allow for full word response in confirmation, allow for failure case of read_line. Co-authored-by: Casey Rodarmor <[email protected]>
could not be read.
a depencency that requires confirmation is denied.
I've added in the confirmation during the running of dependencies. Now, if a recipe that requires confirmation is run as a dependency and is not confirmed then it will return an error of type The confirmation is carried out at the start of the |
Apologies, on testing a bit I realised that I've added in a double confirm. I'll figure out the best way to resolve this and then update the pull. |
Aside from the double confirm, that all sounds good. I think returning an error if a recipe isn't confirmed is sensible. I think that if we get to a recipe that needs confirmation, and it isn't confirmed, we can abort the whole run, and not run any other recipes. Although it is true that we could run any recipes which aren't dependencies of the unconfirmed recipe, not running them doesn't seem like a big deal. Also, this will require a couple of tests: One that a recipe that requires and receives confirmation runs, and one that a recipe which requires confirmation but doesn't receive it does not run. |
Also, if you feel like adding a |
Ok, that makes things easier then, I've got a version working that does that so I'll just plow on with it. Tests to come with that in the next commit. |
I was just wondering on the name. yes is a bit ambiguous, maybe |
Updated readme to reflect new attribute, and added a TOC. Added new error type, NotConfirmed, which returns the name of the recipe that was not confirmed for running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tweaked a few error messages, as well as printed the error confirmation message to stderr, which is also line-buffered, so no need to flush.
Thanks for the PR!
This would add a "Confirm" attribute that requests confirmation before running a recipe. Runs prior to evaluation, and defaults to not running. Potential solution to issue #1711.