Commit8a4879b5Recorded27 Jul 2026Repositorysigil-args
Support nested command dispatch
Changed
package.sgl | 2 +-
src/sigil/args.sgl | 5 +++--
test/test-args.sgl | 10 ++++++++++
3 files changed, 14 insertions(+), 3 deletions(-)Diff
package.sglmodified
@@ -4,7 +4,7 @@
4
5
(package 6
name: "sigil-args"−7
version: "0.17.0"+7
version: "0.18.0" 8
sigil: "^0.17" 9
description: "Command-line argument parsing for Sigil" 10
url: "https://codeberg.org/sigil/sigil-args"src/sigil/args.sglmodified
@@ -293,7 +293,8 @@
293
opts: (parse-result-opts sub-result) 294
args: (parse-result-args sub-result) 295
errors: (parse-result-errors sub-result)−296
subcommand: matched-subcmd+296
subcommand: (or (parse-result-subcommand sub-result)+297
matched-subcmd) 298
passthrough: (parse-result-passthrough sub-result))) 299
;; Not a subcommand - it's a positional arg 300
(parse-args-loop options subcommands rest opts@@ -671,7 +672,7 @@
672
(newline)) 673
errors) 674
(newline)−674
(print-help cmd)+675
(print-help target-cmd) 676
(exit 1)) 677
678
;; Subcommand matched - run its handlertest/test-args.sglmodified
@@ -293,4 +293,14 @@
293
(let ((help (generate-help (command name: "run" passthrough: #t)))) 294
(assert-true (string-find help "[-- args...]")))) 295
+296
(test "nested subcommands preserve the deepest matched command"+297
(let* ((run (command name: "run" passthrough: #t))+298
(project (command name: "project" subcommands: (list run)))+299
(root (command name: "sigil" subcommands: (list project)))+300
(result (parse-args root '("project" "run" "build" "--" "-v"))))+301
(assert-null (parse-result-errors result))+302
(assert-equal "run" (command-name (parse-result-subcommand result)))+303
(assert-equal '("build") (parse-result-args result))+304
(assert-equal '("-v") (parse-result-passthrough result))))+305
306
(run-tests)