Feature - Rejected Better "either" support in CLI

Catch-22

Active member
It would be nice if the CLI "either" keyword could be used as a directive for any action that could succeed or fail, so you could do:

either use 1 Angry Farmer candy, use 2 Tasty Fun Good rice candy

but also do:

either cast 1 Donho's Bubbly Ballad, use 1 Recording of Donho's Bubbly Ballad

and:

either pulverize 1 item, csend item to wadbot

I know ASH can accomplish all of these things easily, but it's nice to have things like this in the CLI too.
 
Last edited:

slyz

Developer
I guess the problem is that CLI commands don't really have return values.

The "use either X item1, Y item2" command simply checks whether you have X item1 in your inventory and if its consumption type matches the version of "use" being used. If these conditions are met, it launches the UseItemRequest and returns. If not, it does the same for item2. There is no checking for success after the request is posted.

An "either" command that works the same way would need to parse what command is being used (use, eat, cast, csend...), verify if the conditions are met (amount of items, if you have the skill and enough max MP...), and launch the request for the first command which looks like it might work.

To do this, we would need to either:
- limit the number of commands that can be used with "either" - probably just use and cast at first
- add a function to all the AbstractCommands that checks whether a command looks like it will work

That sounds like a lot of work for something that can already be easily done in ASH, where functions already have return values, and ones more elaborated than checking KoLmafia.permitsContinue().

I don't see a purely CLI "either" command happening.
 

Bale

Minion
I agree that it would be best to reject this feature since it is a call for CLI to turned into ASH. Even Catch-22 seems to know that. Why would it be good to add this to CLI when the purpose is definitely treading in the direction of using a real script.
 

Catch-22

Active member
Yeah I'm happy for this to be rejected.

Originally I had it in mind to be used for the default CLI action to obtain effects from different actions (like the cast vs. use recordings). As roippi handled this in a different way, the primary use case for this command no longer exists.

FWIW, if someone does need something similar to "either" in the CLI, it can be done in a hackish way like so:

ashq (cli_execute("command1")||cli_execute("command2"))

but if you're going to do that, you may as well just use ASH functionality :)
 
Top