On Tuesday, October 11, 2016 at 9:50:12 PM UTC-4, Ben Greenman wrote:
> Indirect answer: could you use `command-line` instead?
>
>
>
> #lang racket/base
> (require racket/cmdline)
>
>
> (define input-from (make-parameter #f))
>
>
> (command-line
> #:program "sample"
> #:once-each
> [("-i" "--input-file")
> i
> "Use <input_file> as the input file."
> (input-from i)]
> #:args (file)
> (printf "my argument is: ~a\n" file)
> ;; do things with `file` and `input-from` here
> )
>
>
> On Tue, Oct 11, 2016 at 9:24 PM, Ian Thomas <[email protected]> wrote:
> I'm trying to add a simple command line interface to a program and receive
> the following error:
>
>
>
> parse-command-line: expected argument of type <table as a list of
> flag-list/procedure pairs (spec-line help list strings must match procedure
> arguments)>; given: '((once-each (("-i" "--input\
>
> -file") #<procedure:...sis/com_line.rkt:12:25> ("Use <input_file> as the
> input file."))))
>
> context...:
>
>
>
> The command should take a single flag and an input file as arguments. Code
> below. Any help would be much appreciated.
>
>
>
> #lang racket
>
>
>
> (require racket/base
>
> racket/cmdline)
>
>
>
> (parse-command-line "com_line"
>
> ;; argv
>
> (current-command-line-arguments)
>
> ;; table
>
> `((once-each
>
> [("-i" "--input-file")
>
> ,(lambda (flag in) (displayln "Using <in>"))
>
> ("Use <input_file> as the input file.")]))
>
> ;; finish-proc
>
> (lambda (flag-accum file) file)
>
> ;; help-proc
>
> (lambda () (displayln "com_line -i | --input-file input
> file"))
>
> ;; unknown-proc
>
> (lambda (unknown_flag) (displayln "Unknown flag:
> <unknown_flag>")))
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
>
> For more options, visit https://groups.google.com/d/optout.
I'd like to handle usage - help-proc - and unknown flags - unknown-proc - and
the documentation states you need to use parse-command-line and not
command-line to achieve this.
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.