cli.ts 682 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { promisified } from './tauri'
  2. export interface ArgMatch {
  3. /**
  4. * string if takes value
  5. * boolean if flag
  6. * string[] or null if takes multiple values
  7. */
  8. value: string | boolean | string[] | null
  9. /**
  10. * number of occurrences
  11. */
  12. occurrences: number
  13. }
  14. export interface SubcommandMatch {
  15. name: string
  16. matches: CliMatches
  17. }
  18. export interface CliMatches {
  19. args: { [name: string]: ArgMatch }
  20. subcommand: SubcommandMatch | null
  21. }
  22. /**
  23. * gets the CLI matches
  24. */
  25. async function getMatches(): Promise<CliMatches> {
  26. return await promisified<CliMatches>({
  27. module: 'Cli',
  28. message: {
  29. cmd: 'cliMatches'
  30. }
  31. })
  32. }
  33. export { getMatches }