Skip to content

Support "rest" arguments at the command line #10

Description

@countvajhula

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions