Skip to content
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

Support "rest" arguments at the command line #10

Open
countvajhula opened this issue Sep 21, 2022 · 0 comments
Open

Support "rest" arguments at the command line #10

countvajhula opened this issue Sep 21, 2022 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@countvajhula
Copy link
Owner

countvajhula commented Sep 21, 2022

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 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 constraint to pass multiple arguments via a flag.

@countvajhula countvajhula added the help wanted Extra attention is needed label Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant