AtlatestRepositorysigil-args
sigil-args / treeREADME.md
1
# sigil-args3
Declarative command-line argument parsing for [Sigil](https://codeberg.org/sigil/sigil).5
Defines CLIs as composable record values: options, commands, subcommands, with automatic help generation.7
## Usage9
```scheme10
(import (sigil args))12
(define cli13
(command14
name: "greet"15
description: "Print a greeting"16
options: (list17
(option name: 'name short: #\n long: "name"18
value: "NAME" default: "World")19
(option name: 'loud short: #\l long: "loud"20
description: "Use uppercase"))21
handler: (lambda (opts args)22
(let ((greeting (format "Hello, ~a!" (alist-get 'name opts))))23
(display (if (alist-get 'loud opts)24
(string-upcase greeting)25
greeting))26
(newline)))))28
(run-command cli (cdr (command-line)))29
```31
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.33
Commands that forward argv can declare `passthrough: #t`. Their handler takes34
`(opts args passthrough)`: `args` contains operands before `--`, while35
`passthrough` contains the exact unparsed tail. It is `#f` when the separator is36
absent and `()` for an explicitly empty tail.38
See [`docs/args.md`](docs/args.md) for the full reference.40
## Building42
```sh43
sigil deps install44
sigil build45
sigil test46
```48
For local development against an in-tree `sigil-lang` checkout:50
```sh51
sigil build --redirects ./dev-redirects.sgl52
```54
## License56
BSD-3-Clause. See [LICENSE](LICENSE) (license header lives in `package.sgl`).