-
Notifications
You must be signed in to change notification settings - Fork 124
Description
Follow up of #684.
This is some - late (sorry) - insight on #685. I've been trying to leverage cmd2 to help me with testing so here is my process: I have 2 scripts.
generate_transcripts et run_tests. run_tests fails as soon as a test fail, perfect !
Similarly, I would like generate_transcripts to exit when it fails to generate a transcript.
# Make it fail if any call fails
set -o errexit
function gen_transcript()
{
suffix="$1"
mptcpanalyzer "load tests/script_${suffix}.txt -t tests/trans_${suffix}.txt" "quit"
}
gen_transcript "tcp"
gen_transcript "mptcp"
...
E.g., I would like to have my program to stop with a non 0 exit code when "load script.txt -t text.txt" fails.
While the PR #685 targeted one command, I feel like there is the possibility to abstract the mechanism to apply it more generally. Like a flag --exit-on-error.
I don't know about the API, if it should be added per-command:
@with_argparser(parser)
@exit_on_error
def do_mycommand
or as a global flag:
my_cmd2_program --exit-on-error "load test.txt -t test.txt"
What do you think ?