mirror of
https://github.com/tauri-apps/tauri-plugin-cli.git
synced 2026-01-31 00:45:18 +01:00
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com> Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/6590505706 Co-authored-by: lucasfernog <lucasfernog@users.noreply.github.com>
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
/**
|
|
* @since 2.0.0
|
|
*/
|
|
interface ArgMatch {
|
|
/**
|
|
* string if takes value
|
|
* boolean if flag
|
|
* string[] or null if takes multiple values
|
|
*/
|
|
value: string | boolean | string[] | null;
|
|
/**
|
|
* Number of occurrences
|
|
*/
|
|
occurrences: number;
|
|
}
|
|
/**
|
|
* @since 2.0.0
|
|
*/
|
|
interface SubcommandMatch {
|
|
name: string;
|
|
matches: CliMatches;
|
|
}
|
|
/**
|
|
* @since 2.0.0
|
|
*/
|
|
interface CliMatches {
|
|
args: Record<string, ArgMatch>;
|
|
subcommand: SubcommandMatch | null;
|
|
}
|
|
/**
|
|
* Parse the arguments provided to the current process and get the matches using the configuration defined [`tauri.cli`](https://tauri.app/v1/api/config/#tauriconfig.cli) in `tauri.conf.json`
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* import { getMatches } from '@tauri-apps/plugin-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 2.0.0
|
|
*/
|
|
declare function getMatches(): Promise<CliMatches>;
|
|
export type { ArgMatch, SubcommandMatch, CliMatches };
|
|
export { getMatches };
|