-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print full --help message on error when no arguments are passed? #16
Labels
Comments
Thanks for reporting! I'll look into it this week: should be fixable :-) |
I second that! |
Here's a workaround: #!/usr/bin/env Rscript
'Naval Fate.
Usage:
naval_fate.R
naval_fate.R ship new <name>...
naval_fate.R ship <name> move <x> <y> [--speed=<kn>]
naval_fate.R ship shoot <x> <y>
naval_fate.R mine (set|remove) <x> <y> [--moored | --drifting]
naval_fate.R (-h | --help)
naval_fate.R --version
Options:
-h --help Show this screen.
--version Show version.
--speed=<kn> Speed in knots [default: 10].
--moored Moored (anchored) mine.
--drifting Drifting mine.
' -> doc
if(length(commandArgs(trailingOnly = TRUE)) == 0L) {
docopt:::help(doc)
quit()
}
library(docopt)
arguments <- docopt(doc, version = 'Naval Fate 2.0')
print(arguments) |
Thanks for the suggestion! Will look into it this weekend.
Best,
Edwin
Op vr 6 nov. 2020 17:40 schreef Ramiro Magno <[email protected]>:
… Here's a workaround:
#!/usr/bin/env Rscript
'Naval Fate.Usage: naval_fate.R naval_fate.R ship new <name>... naval_fate.R ship <name> move <x> <y> [--speed=<kn>] naval_fate.R ship shoot <x> <y> naval_fate.R mine (set|remove) <x> <y> [--moored | --drifting] naval_fate.R (-h | --help) naval_fate.R --versionOptions: -h --help Show this screen. --version Show version. --speed=<kn> Speed in knots [default: 10]. --moored Moored (anchored) mine. --drifting Drifting mine.' -> doc
if(length(commandArgs(trailingOnly = TRUE)) == 0L) {
docopt:::help(doc)
quit()
}
library(docopt)arguments <- docopt(doc, version = 'Naval Fate 2.0')
print(arguments)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#16 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEEOHEPRK6X36I2F4MBIP3SOQRGRANCNFSM4B6TICWQ>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First of all - big thank you to the authors of this package. My scripts became 100 lines lighter and less bug-prone.
My issue is with the failing message of the script when no arguments are passed. Right now it prints this kind of message:
Can instead of printing this rather cryptic error the script simply print out the full
--help
message? Or maybe just the simple "usage:" line without the "Error in docopt"? Coming fromoptparse
this is the only thing I miss. Maybe there is already a way around that?Thanks a lot.
The text was updated successfully, but these errors were encountered: