odb/shml

`confirm` function

jmervine opened this issue · 4 comments

Add confirm with usage like so:

# with success callback
on_succes() {
    echo "Success"
}
confirm "Did you succeed?" "on_success"

# with success and failure callbacks
on_failure() {
    echo "Failed"
}
confirm "Did you succeed?" "on_success" "on_failure"

# w/o callbacks
config "Did you succeed?" && echo "Why yes, yes I did!"

@jdorfman thoughts?

In the same vein, I could add a dialog as well, which displays a message and takes a response string an returns it. The idea being to emulate javascript's confirm and dialog here, all nicely encapsulated.

confirm should accept the following as an affirmative: y, Y, yes, Yes, YES, ok, OK, Ok, okay, Okay, OKAY, continue, Continue, CONTINUE, proceed, Proceed, PROCEED, success, Success, SUCCESS, successful, Successful, SUCCESSFUL, good, Good, GOOD...

I can also surface SHML_CONFIRM_SUCCESS, which allow for user defined values.

Everything else would be negative/no.

@jdorfman can you think of anything else?

I would add k, K

Love this: "Why yes, yes I did!"

I think it is never too late to revive a 2-year-old feature request. This should be v1.1.0

image

Edit: I'll work on the docs