cli
Parse arguments from your Command Line Interface.
This package is also accessible with window.__TAURI__.cli
when build.withGlobalTauri
in tauri.conf.json
is set to true
.
Interfacesβ
ArgMatch
β
Since: 1.0.0
Propertiesβ
occurrences
β
occurrences:
number
Number of occurrences
Defined in: cli.ts:27
value
β
value:
null
|string
|boolean
|string
[]
string if takes value boolean if flag string[] or null if takes multiple values
Defined in: cli.ts:23
CliMatches
β
Since: 1.0.0
Propertiesβ
args
β
Defined in: cli.ts:42
subcommand
β
subcommand:
null
|SubcommandMatch
Defined in: cli.ts:43
SubcommandMatch
β
Since: 1.0.0
Propertiesβ
matches
β
matches:
CliMatches
Defined in: cli.ts:35
name
β
name:
string
Defined in: cli.ts:34
Functionsβ
getMatches
β
getMatches():
Promise
<CliMatches
>
Parse the arguments provided to the current process and get the matches using the configuration defined tauri.cli
in tauri.conf.json
Example
import { getMatches } from '@tauri-apps/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
}
Since: 1.0.0
Returns: Promise
<CliMatches
>