tauri-init.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const parseArgs = require('minimist')
  2. /**
  3. * @type {object}
  4. * @property {boolean} h
  5. * @property {boolean} help
  6. * @property {string|boolean} f
  7. * @property {string|boolean} force
  8. * @property {boolean} l
  9. * @property {boolean} log
  10. * @property {boolean} d
  11. * @property {boolean} directory
  12. */
  13. const argv = parseArgs(process.argv.slice(2), {
  14. alias: {
  15. h: 'help',
  16. f: 'force',
  17. l: 'log',
  18. d: 'directory',
  19. t: 'tauri-path'
  20. },
  21. boolean: ['h', 'l']
  22. })
  23. if (argv.help) {
  24. console.log(`
  25. Description
  26. Inits the Tauri template. If Tauri cannot find the tauri.conf.json
  27. it will create one.
  28. Usage
  29. $ tauri init
  30. Options
  31. --help, -h Displays this message
  32. --force, -f Force init to overwrite [conf|template|all]
  33. --log, -l Logging [boolean]
  34. --directory, -d Set target directory for init
  35. --tauri-path, -t Path of the Tauri project to use (relative to the cwd)
  36. `)
  37. process.exit(0)
  38. }
  39. const init = require('../dist/init')
  40. init({
  41. directory: argv.d || process.cwd(),
  42. force: argv.f || null,
  43. logging: argv.l || null,
  44. tauriPath: argv.t || null
  45. })