kcmerrill / alfred

(v0.2) Even Batman needs a little help. Task runner. Automator. Build system.
MIT License
63 stars 14 forks source link

run something based on the result (return codes) of the multitask? #33

Closed kohlerm closed 7 years ago

kohlerm commented 7 years ago

First off all. Thanks for open sourcing this tool! This is very similiar to something I wanted to build since quite some time!

One thing I'm wondering about is the return value for multiple tasks Currently it looks like of I have a task that calls other tasks via multitask (or tasks) and one of those tasks faisl, then ok still evaluates to true. E.g.

for speak: multitask: say.hello say.howareyou ok: ok

if for example say.howareyou fails. it will still call the ok task.

as far as I understand the reason is that the ok task is run because the (empty) command for speak worked fine. Is there a way to run something based on the result of the multitask?

:

kcmerrill commented 7 years ago

@kohlerm The short answer is there isn't(at least not at the moment).

That was a design decision when I was creating alfred in a vacuum and I was it's only user :)

I actually thought long and hard about adding that in, but the reason I ended up not failing the task due to tasks and/or multitasks was due in part the ok/fail you can add to the other tasks(either the multitasks or regular tasks).

I suppose the idea being, if one of the tasks fails, you can either a.) fix it via the fail key, or you can exit the app completely if it's unrecoverable.

So if we take the example provided it would look something like this:


say.howareyou:
    summary: I will do something!
    command: ls/doesnotexistandwillfail
    fail: task.that.fixes.this.failure

OR

say.howareyou:
    summary: I will do something!
    command: ls/doesnotexistandwillfail
    exit: 1
kcmerrill commented 7 years ago

Sorry, one more quick thought, if that isn't sufficient, then I'd be curious your use case.

kohlerm commented 7 years ago

Thanks for the hint. Yes that workaround is also something that came to my mind later on. I don't have a concrete use case yet. I was thinking about the overall model. I was thinking about something that would be executed depending on whether that multiple tasks would finish successfully or not. One idea could also be to invent a different syntax such as.

tasks: (task1.1 task1.2 task1.3) task2 E.g everything in () would be executed in parallel in this case all the task1.x If one of them fails the whole group would fail and behave just like a normal task that fails.

kcmerrill commented 7 years ago

Interesting take.

It would require some reworking though.

Currently, tasks or anything that have () will basically pass in the params. Example:

say:
    summary: say something
    command: echo {{ index . Args 0 }}

blurt:
    multitask: say(hello) say(goodbye) say(wootwoot)
kohlerm commented 7 years ago

Sure, makes sense to use () for arguments, any other free chars could be used [], but next question would be how to also get return values. I think that could become complicated ...