Hi, When using "guile-config" for declaring my CLIs I've noticed that if I define an argument as non-optional for a command, then trying to display the --help of that command fails.
Consider the following script which displays "What yummy apple!" when it's run like "$ eat apple": #+BEGIN_SRC scheme (use-modules (config) (config api) (ice-9 format) (ice-9 match)) ;;; CONSTANTS ;;; ========= (define FRUITS (list "apple" "banana" "kiwi" "mango")) ;;; VALIDATORS ;;; ========== (define (fruit? fruit) (member fruit FRUITS)) ;;; ARGUMENTS AND OPTIONS ;;; ===================== (define fruit (argument (name 'fruit) (synopsis "The name of a fruit.") (example "apple") (optional? #false) (test fruit?))) ;;; CLI SPECIFICATION ;;; ================= (define spec (configuration (name 'eat) (synopsis "Eat imaginary fruits.") (version "1.0") (arguments (list fruit)))) ;;; CLI DISPATCHER ;;; ============== (define (dispatcher command spec) #| Execute the appropriate procedure for the given COMMAND if it is part of the given command-line interface specification. COMMAND (list of strings) A list of strings that represent a command-line instruction passed to the program (see the Guile command-line procedure). SPEC (Configuration) A <configuration> record as specified by the guile-config library specifying the command-line interface of the program. RESULT Execute the COMMAND or display help information if the COMMAND is not recognized. |# (let* ((options (getopt-config-auto command spec)) (fruit (option-ref options '(fruit)))) (catch 'match-error (lambda () (match (full-command options) ((_) (format #true "What yummy ~a!!~%" fruit)))) (lambda (. args) (begin (display "ERROR: Command not found.") (newline) (newline) (emit-help options)))))) ;;; RUN ;;; === (dispatcher (command-line) spec) #+END_SRC Now, when I try to display the help information of the "eat" command, I get this message: #+BEGIN_EXAMPLE $ eat --help error: eat: argument must be specified: fruit Usage: eat Options: #+END_EXAMPLE Is this a bug or am I doing something wrong? --- https://sirgazil.bitbucket.io/