From: Zoltán K. <zo...@pr...> - 2025-07-06 14:09:05
|
I believe you are looking for something like this unless I am mistaken: USING: combinators command-line io kernel namespaces sequences ; IN: foo ! Help text : help ( -- ) "Usage: foo [command]" print "Available commands:" print " greet - Print a greeting" print " help - Show this message" print ; ! Command: greet : greet ( -- ) "Hello from Factor!" print ; ! Dispatch function: handles command and its arguments : dispatch ( cmd rest -- ) { { "greet" [ drop greet ] } { "help" [ drop help ] } [ drop "Unknown command: " swap append print help ] } case ; ! Entry point : run ( -- ) command-line get dup empty? [ drop help ] [ dup rest swap first dispatch ] if ; MAIN: run You can extend it to your liking. On Saturday, July 5th, 2025 at 9:34 PM, toastal <to...@po...> wrote: > > Are you trying to use something like a “sub command” feature? > > > Yep. Like Cmdliner. > > https://ocaml.github.io/odoc/cmdliner/cmdliner/Cmdliner/Cmd/index.html > > The ability to call ./my-factor-script cmd sub-cmd --help. > > > _______________________________________________ > Factor-talk mailing list > Fac...@li... > https://lists.sourceforge.net/lists/listinfo/factor-talk |