(use cli-max) (define-arguments (v verbose) (i input-file FILE-NAME required: #t) (f filter (* EXPRESSION) as: input-filter) (l limit NUMBER convert: to-number default: 10)) ;; defines the following variables in the current scope: ;; verbose? ; a boolean since no third argument was given ;; input-file ; a string ;; input-filter ; a list of zero or more strings ;; limit ; a number, 10 if not given (unless (null? (command-line-errors)) (for-each (lambda (error) (fprintf (current-error-port) "~A~%")) (command-line-errors)) (newline) (print (command-usage)) (exit 1)) (define-sub-command commit (m message required: #t) files-to-commit (+ FILES)) ;; global arguments defined above go before a sub command ;; sub command specific arguments follow ;; ;; program -v commit -m foo bar baz ;; verbose? ; #t ;; (sub-command) ; commit ;; message ; "foo" ;; files-to-commit ; ("bar" "baz")