Skip to content

cli

Parse arguments from your Command Line Interface.

Interfaces

ArgMatch

Properties

PropertyTypeDescriptionDefined in
occurrencesnumberNumber of occurrences
valuenull | string | boolean | string[]string if takes value boolean if flag string[] or null if takes multiple values

CliMatches

Properties

PropertyTypeDefined in
argsRecord<string, ArgMatch>
subcommandnull | SubcommandMatch

SubcommandMatch

Properties

PropertyTypeDefined in
matchesCliMatches
namestring

Functions

getMatches()

function getMatches(): Promise<CliMatches>

Parse the arguments provided to the current process and get the matches using the defined configuration`

@example

import { getMatches } from '@crabnebula/taurify-api/cli';
const matches = await getMatches();
if (matches.subcommand?.name === 'run') {
// `./your-app run $ARGS` was executed
const args = matches.subcommand?.matches.args
if ('debug' in args) {
// `./your-app run --debug` was executed
}
} else {
const args = matches.args
// `./your-app $ARGS` was executed
}

Returns

Promise<CliMatches>