Files
tauri/tooling/api/src/cli.ts
2021-04-12 22:44:50 -03:00

45 lines
899 B
TypeScript

// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import { invokeTauriCommand } from './helpers/tauri'
export 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
}
export interface SubcommandMatch {
name: string
matches: CliMatches
}
export interface CliMatches {
args: { [name: string]: ArgMatch }
subcommand: SubcommandMatch | null
}
/**
* Gets the CLI matches.
*
* @returns A promise resolving to cli matches.
*/
async function getMatches(): Promise<CliMatches> {
return invokeTauriCommand<CliMatches>({
__tauriModule: 'Cli',
message: {
cmd: 'cliMatches'
}
})
}
export { getMatches }