Command-line argument parsing for Sigil.
- Scheme 100%
sigil-args
Declarative command-line argument parsing for Sigil.
Defines CLIs as composable record values: options, commands, subcommands, with automatic help generation.
Usage
(import (sigil args))
(define cli
(command
name: "greet"
description: "Print a greeting"
options: (list
(option name: 'name short: #\n long: "name"
value: "NAME" default: "World")
(option name: 'loud short: #\l long: "loud"
description: "Use uppercase"))
handler: (lambda (opts args)
(let ((greeting (format "Hello, ~a!" (alist-get 'name opts))))
(display (if (alist-get 'loud opts)
(string-upcase greeting)
greeting))
(newline)))))
(run-command cli (cdr (command-line)))
Supports short flags (-v, -vvv, -vf), long flags (--verbose, --no-verbose), values (-o val, --output=val), -- to stop option parsing, env-var fallback, choice restriction, multi-value (repeatable) options, negatable booleans, custom parsers, and required flags.
See docs/args.md for the full reference.
Building
sigil deps install
sigil build
sigil test
For local development against an in-tree sigil-lang checkout:
sigil build --redirects ./dev-redirects.sgl
License
BSD-3-Clause. See LICENSE (license header lives in package.sgl).