-
Notifications
You must be signed in to change notification settings - Fork 24
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
Generalize chain
?
#11
Comments
Intriguing idea. I wrote the original chain code, with the goal of being as simple and non-invasive to the current code base (at the time) as possible. Currently, it's basically just a dumb list of function pointers, I'd have to have a bit of a think as to how it could be implemented (and parsed!) |
Because I can't help myself, I'm prototyping this to see how it could work. |
I think you'd need an extra attribute in |
I'm actually thinking of using the terms |
I'm fine with it. |
Got a prototype semi-working. It's going to need a bit more time in the oven before I push it. EDIT: Hopefully, morning brain might be a bit more with it than midnight brain... |
I don't know what @shermp has in mind yet, but I'd probably implement this myself by adding an Another idea I'm considering is to add another option to |
This allows for conditional menu action execution, as discussed in #11
Ok, I've pushed a prototype to shermp/conditional_actions. It's not extensively tested, but I haven't managed to break it FWIW. More testing can occur if @geek1011 thinks my approach is ok. Here's the quick doc I wrote for the feature:
The approach I took was a "jump ahead" approach. The jump distances are set during config parsing, and during the loop in The approach means that one or both options may be set in the config, and the order of the two doesn't matter. |
Thanks! I'll have a closer look at this tomorrow or the day after. One thought: That point about the order is interesting. The advantage of your approach is the clarity, but it comes at the cost of flexibility with action chaining. If anyone else has opinions on this tradeoff, I'd like to hear them. |
I hadn't really thought of conditional chains. My first impression of that idea is "it could get messy". Note, with my approach, each action can have a condition attached to it if you like. Makes it very clear what condition belongs with which action. eg:
|
OTOH, I was thinking more along the lines of shell script So, you could do something like:
|
Does anybody else have an opinion on this? |
The behavior of |
As this is @baskerville 's request, I'm happy with whatever you guys are happy with. Whether that's my approach, or a different one is fine by me. |
Ok, I'll probably go with my approach then. Thanks for working on this, though, @shermp. |
@baskerville, can you test this: https://github.com/geek1011/NickelMenu/suites/672525752/artifacts/6077878? Here's what I tested this with myself:
|
It seems to work fine, thanks. |
The current behavior is to abort a chain of actions on the first failure.
Would it be possible to introduce the following variants of
chain
:and_then
: only executes if the last executed action succeeded.or_else
: only executes if the last executed action failed.The text was updated successfully, but these errors were encountered: