Paste: subcommand example
Author: | mrjbq7 |
Mode: | factor |
Date: | Wed, 9 Jul 2025 22:56:37 |
Plain Text |
cat foo.factor f
USING: command-line.parser math ;
IN: foo
CONSTANT: COMMANDS H{
{
"add"
{
T{ option
{ name "a" }
{ type integer }
{ #args 1 }
}
}
}
{
"subtract"
{
T{ option
{ name "s" }
{ type integer }
{ #args 1 }
}
}
}
}
MAIN: [
COMMANDS [ ] with-commands
]
Author: | mrjbq7 |
Mode: | text |
Date: | Wed, 9 Jul 2025 22:58:57 |
Plain Text |
$ ./factor foo.factor
$ ./factor foo.factor --help
Usage:
factor foo.factor [--help] [command]
Arguments:
command {add,subtract}
Options:
--help show this help and exit
$ ./factor foo.factor add --help
Usage:
factor foo.factor add [--help] [a]
Arguments:
a
Options:
--help show this help and exit
$ ./factor foo.factor multiply
ERROR: Invalid value 'multiply' for option 'command'
New Annotation