You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#! /usr/bin/env rakuusev6.d;
multiMAIN('foo') { say'foo subcommand handler' }
multiMAIN('bar') { say'bar subcommand handler' }
subUSAGE {
print$*USAGE~"\n\n"~qq:to/USAGE/; Some example text USAGE
}
When I call ./test.raku --help I get the usage info and the exit code is success (0) which is expected, as I correctly and explicitly requested usage info by --help. But when I call ./test.raku random-text or just ./test.raku I get the same usage info but it exits with success (0) while it should be error non-zero exit code it’s arguments parsing failure.
Expected Behavior
When calling ./foo.raku or ./foo.raku random-jibberish to get a non-zero (error) exit code.
Actual Behavior
I get successful exit code (0).
Steps to Reproduce
Save the example from “The Problem” section above to test.raku file and chmod +x test.raku
Run this:
$ ./foo.rakuUsage: ./foo.raku foo ./foo.raku barSome example text
$ echo$?0
$ ./foo.raku any-random-textUsage: ./foo.raku foo ./foo.raku barSome example text
$ echo$?0
Even though it's an older approach, it is trivial
to provide `USAGE` the same exit code logic as for
`GENERATE-USAGE`:
If a `--help` is part of the invocation, exit 0.
Otherwise, exit 2.
Addresses R#5514 (#5514).
USAGE is the older way to define things. In the code there is a comment mentioning that a deprecated message should be shown but it looks like this has not yet been added.
The newer approach is GENERATE-USAGE(&main, |capture) {...}, which is more flexible but also more complicated. However, it will print to STDERR and exit with status 2 if triggered without --help.
Since USAGE leaves the user in charge of printing -- and doesn't provide access to passed arguments -- there is no way to conditionally divert the erroneous cases to STDERR.
However, at first glance it does seem trivial to at least conditionally set the exit status for USAGE, so I've submitted a PR to do just that.
Even though it's an older approach, it is trivial
to provide `USAGE` the same exit code logic as for
`GENERATE-USAGE`:
If a `--help` is part of the invocation, exit 0.
Otherwise, exit 2.
Addresses R#5514 (#5514).
The Problem
Take for instance
test.raku
:When I call
./test.raku --help
I get the usage info and the exit code is success (0) which is expected, as I correctly and explicitly requested usage info by--help
. But when I call./test.raku random-text
or just./test.raku
I get the same usage info but it exits with success (0) while it should be error non-zero exit code it’s arguments parsing failure.Expected Behavior
When calling
./foo.raku
or./foo.raku random-jibberish
to get a non-zero (error) exit code.Actual Behavior
I get successful exit code (0).
Steps to Reproduce
Save the example from “The Problem” section above to
test.raku
file andchmod +x test.raku
Run this:
Environment
rakudo -v
orraku -v
):The text was updated successfully, but these errors were encountered: