Command-line arguments
icore receives process.argv.slice(2) and separates command names and positional arguments from options. The selected command's schema determines how values are read and checked. Four forms are supported.
- Long options
--name valueand--name=value. - Boolean flags
--flagand--no-flag. - Short names declared in the schema, such as
-fand-n value. - The
--terminator before positional arguments.
Long options
Pass the name and value as separate arguments.
node dist/cli.js users get --name Alice
Parsing yields this value.
{
"name": "Alice"
}
An equals sign gives the same result.
node dist/cli.js users get --name=Alice
String and number options can take a value that begins with -. In this example the schema declares label as type: 'string' and limit as type: 'number'.
node dist/cli.js search --label -draft --limit -1
Boolean flags
The flag name sets the option to true.
node dist/cli.js reports list --archived
--no-<name> sets a known boolean option to false when its schema allows negation.
node dist/cli.js reports list --no-archived
An explicit value after an equals sign is rejected.
node dist/cli.js reports list --archived=true
node dist/cli.js reports list --archived=false
As a separate argument, the value leaves archived set to true and false remains positional.
node dist/cli.js reports list --archived false
Short names
Assign -v to --verbose in the option schema.
const options = {
verbose: {
type: 'boolean',
alias: 'v'
}
} as const;
The user calls the short form.
node dist/cli.js users get -v
The handler receives the value under the long name.
{
"verbose": true
}
For string and number options, put the short name and its value in separate arguments.
const options = {
name: {
type: 'string',
alias: 'n'
},
limit: {
type: 'number',
alias: 'l'
}
} as const;
node dist/cli.js users get -n Alice -l 10
{
"name": "Alice",
"limit": 10
}
A value attached directly to the name is rejected.
node dist/cli.js users get -nAlice
Pass each flag separately. A group of short names in one argument is rejected.
node dist/cli.js users get -abc
Option terminator
-- stops option parsing and is removed from the result. All following arguments are positional, even when they start with -.
node dist/cli.js search -- --name Alice -v
The command name is followed by the positional arguments --name, Alice, and -v.
Duplicate options
Pass each option once. A repeated long name is rejected.
node dist/cli.js users get --format json --format table
Passing both the long and short name of one option is also a duplicate.
node dist/cli.js users get --verbose -v
Unknown options
An unknown long option raises a validation error.
node dist/cli.js users get --unknown value
An undeclared short argument remains positional. Validation rejects it when the command forbids extra positional arguments.
See the CLI patterns for global flags, shared options, and renaming.