(module args (;; Option lists args:parse args:help-options args:ignore-unrecognized-options args:accept-unrecognized-options make-args:option ;; Usage printing args:usage args:width args:separator args:indent args:make-option) (import scheme chicken extras) (require-extension srfi-1 srfi-13 srfi-37) ;;; macro: (args:make-option (OPTION-NAME ...) ARG-TYPE [BODY]) ;; Make an args:option record, suitable for passing to args:parse. ;; ;; OPTION-NAME ... is a sequence of short or long option names. They must be literal ;; symbols; single-character symbols become short options, and longer symbols become ;; long options. So (args:make-option (c cookie) <...>) specifies a short option -c ;; and long option --cookie. Underneath, (c cookie) becomes '(#\c "cookie"), as ;; expected by SRFI 37's OPTION. ;; ;; ARG-DATA is either a pair (ARG-TYPE ARG-NAME) or a plain keyword ARG-TYPE. ;; ARG-TYPE is a keyword that specifies whether the option takes an argument: ;; #:required Argument is required ;; #:optional Argument is optional ;; #:none Does not take an argument (actually, any other value than ;; #:required or #:optional is interpreted as #:none) ;; ARG-NAME, if provided, is a string specifying the name of the argument. ;; This name is used in the help text produced by args:usage. ;; ;; BODY is an optional sequence of statements executed when this option is encountered. ;; Behind the scenes, BODY is wrapped in code which adds the current option and its ;; argument to the final options alist. So, simply leave BODY blank and options ;; will be collected for you. BODY is an option-processor as defined in SRFI 37, ;; and has access to the variables OPT (the current #