countvajhula / countvajhula/cli
Support "rest" arguments at the command line
- Dominant language
- Racket
- Stars
- 15
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Ordinary Racket functions accept individually named arguments, but also packed "rest" arguments using the dot notation:
```
(define (func . args)
body ...)
```
With `#lang cli`, we'd like to support something similar:
```
(program (prog . args)
body ...)
```
and
```
(program (prog . [args "Files to process"])
body ...)
```
... would be ideal. But I seem to recall that it's tricky (impossible?) to match the literal dot in macros. So it may be necessary to use a custom syntax to indicate that arguments should be collected into a list. Example:
```
(program (prog (rest args))
body ...)
```
and
```
(program (prog . (rest [args "Files to process"]))
body ...)
```
Note that Racket's built-in [`command-line`](https://docs.racket-lang.org/reference/Command-Line_Parsing.html#%28form._%28%28lib._racket%2Fcmdline..rkt%29._command-line%29%29) _does_ support this kind of argument packing, and it too is implemented on top of `parse-command-line`, as `#lang cli` is. So it should be possible to leverage the built-in facilities for this.
**Workaround**: At the moment, we can use the [`multi`](https://docs.racket-lang.org/cli/index.html#%28form._%28%28lib._cli%2Fmain..rkt%29._constraint%29%29) constraint to pass multiple arguments via a [flag](https://docs.racket-lang.org/cli/index.html#%28form._%28%28lib._cli%2Fmain..rkt%29._flag%29%29).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.