cli.ts 642 B

12345678910111213141516171819202122232425262728293031323334353637
  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. cmd: 'cliMatches'
  28. })
  29. }
  30. export {
  31. getMatches
  32. }