Skip to main content

Module cli

Module cli 

Source
Expand description

Argument parsing — small, script-focused.

Typical script startup:

(define spec (list (list :name “template” :short “t” :kind :string :required #t) (list :name “verbose” :short “v” :kind :flag)))

(define args (parse-args spec)) (define tpl (alist-get args “template”)) (define verbose? (alist-get args “verbose”)) (define positional (alist-get args “”)) ; leftover positional args

Each spec entry is a plist / alist with: :name — long flag name (required) :short — optional single-char alias :kind — :string | :flag | :int :required — bool; default #f :default — default value when not provided :help — one-line description for (print-usage spec)

parse-args returns an alist mapping name → value; “” (empty string) collects leftover positional args as a list.

(print-usage spec progname) prints a usage banner to stderr.

Functions§

install