Conversation
previously:
$ racket -l- resyntax
does nothing, leaving the user unsure what to do.
After some code/doc search, the user may try
$ racket -l- resyntax/cli
but this again does nothing
$racket -l- resyntax/cli --help
say either "analyze" or "fix" should be used
$racket -l- resyntax/cli analyze
does again nothing
$racket -l- resyntax/cli analyze --help
finally provides some useful guidance.
new behaviour:
$ racket -l- resyntax
displays a message to try the following:
$ racket -l- resyntax/cli --help
Furthermore, all of
$ racket -l- resyntax/cli
$ racket -l- resyntax/cli --analyze
$ racket -l- resyntax/cli --fix
default to adding the "--help" flag so as to provide meaningful help.
Command line parsing has been changed to look more like hierarchical argument
parsing.
A `parameterize-help-if-empty-ccla` form makes the command line arguments
default to #("--help") if they are empty.
The "analyze" and "fix" commands are now parsed properly by `command-line`,
which means they must be written "--analyze" and "--fix".
| (define parsed-modpath (read (open-input-string modpath))) | ||
| (define parsed-suite-name (read (open-input-string suite-name))) | ||
| (set-box! suite (dynamic-require parsed-modpath parsed-suite-name)))) | ||
| (parameterize-help-if-empty-ccla |
There was a problem hiding this comment.
Only this line has changed n this function. The rest is indentation.
| (define parsed-modpath (read (open-input-string modpath))) | ||
| (define parsed-suite-name (read (open-input-string suite-name))) | ||
| (set-box! suite (dynamic-require parsed-modpath parsed-suite-name)))) | ||
| (parameterize-help-if-empty-ccla |
There was a problem hiding this comment.
Only this line has changed in this function. The rest is indentation.
|
The analyze-mode v.s. fix-mode distinction being a flag is definitely something I want to avoid, as it's very unlikely they'll remain as similar as they are now over time and I really want them to look and feel like distinct operations to users. What do you think about making separate |
|
|
||
| ;; If the command line arguments are empty, re-parameterize it to | ||
| ;; default to #("--help") | ||
| (define-syntax-parse-rule (parameterize-help-if-empty-ccla body ...) |
There was a problem hiding this comment.
I think we ought to try to add this to command-line as an opt-in feature. So that we could write something like:
(command-line
#:program-name "foo"
#:print-help-by-default
flags ...)There was a problem hiding this comment.
That would certainly be useful.
|
I don't really understand why Note that the parsing doesn't do much: it merely looks at the first argument, and the But if you really want to split in filse, I would suggest getting rid of |
|
The reason I want to avoid Re: |
The PR does distinguish subcommand-specific flags: says: and while Notice that the help texts and usage lines are different, and, even if the flags were different the PR would still produce subcommand-specific help text. It's really hierarchical. (This could actually relatively be easy to turn into an actual hierarchical-cli library.) [I suppose there's a typo for |
|
So |
|
Indeed it wouldn't, and the help does say so. I agree it goes a little against intuition, although there are a number unix command line tools that do break this property eagerly (like |
|
Yes, that would work. |
|
ok good. Then I'll try to submit a PR to racket/cmdline to allow for non [-+] flags, as well as a PR to racket/cmdline for |
|
Closing this since it's a few years old and has conflicts with the current state of things. Let me know if you want to take another stab at this sometime though. |
See first commit message below.