peertube.ts 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/usr/bin/env node
  2. /* eslint-disable no-useless-escape */
  3. import { registerTSPaths } from '../helpers/register-ts-paths'
  4. registerTSPaths()
  5. import * as program from 'commander'
  6. import { getSettings, version } from './cli'
  7. program
  8. .version(version, '-v, --version')
  9. .usage('[command] [options]')
  10. /* Subcommands automatically loaded in the directory and beginning by peertube-* */
  11. program
  12. .command('auth [action]', 'register your accounts on remote instances to use them with other commands')
  13. .command('upload', 'upload a video').alias('up')
  14. .command('import-videos', 'import a video from a streaming platform').alias('import')
  15. .command('get-access-token', 'get a peertube access token', { noHelp: true }).alias('token')
  16. .command('watch', 'watch a video in the terminal ✩°。⋆').alias('w')
  17. .command('repl', 'initiate a REPL to access internals')
  18. .command('plugins [action]', 'manage instance plugins/themes').alias('p')
  19. .command('redundancy [action]', 'manage instance redundancies').alias('r')
  20. /* Not Yet Implemented */
  21. program
  22. .command(
  23. 'diagnostic [action]',
  24. 'like couple therapy, but for your instance',
  25. { noHelp: true } as program.CommandOptions
  26. ).alias('d')
  27. .command('admin',
  28. 'manage an instance where you have elevated rights',
  29. { noHelp: true } as program.CommandOptions
  30. ).alias('a')
  31. // help on no command
  32. if (!process.argv.slice(2).length) {
  33. const logo = '░P░e░e░r░T░u░b░e░'
  34. console.log(`
  35. ___/),.._ ` + logo + `
  36. /' ,. ."'._
  37. ( "' '-.__"-._ ,-
  38. \\'='='), "\\ -._-"-. -"/
  39. / ""/"\\,_\\,__"" _" /,-
  40. / / -" _/"/
  41. / | ._\\\\ |\\ |_.".-" /
  42. / | __\\)|)|),/|_." _,."
  43. / \_." " ") | ).-""---''--
  44. ( "/.""7__-""''
  45. | " ."._--._
  46. \\ \\ (_ __ "" ".,_
  47. \\.,. \\ "" -"".-"
  48. ".,_, (",_-,,,-".-
  49. "'-,\\_ __,-"
  50. ",)" ")
  51. /"\\-"
  52. ,"\\/
  53. _,.__/"\\/_ (the CLI for red chocobos)
  54. / \\) "./, ".
  55. --/---"---" "-) )---- by Chocobozzz et al.\n`)
  56. }
  57. getSettings()
  58. .then(settings => {
  59. const state = (settings.default === undefined || settings.default === -1)
  60. ? 'no instance selected, commands will require explicit arguments'
  61. : 'instance ' + settings.remotes[settings.default] + ' selected'
  62. program
  63. .on('--help', function () {
  64. console.log()
  65. console.log(' State: ' + state)
  66. console.log()
  67. console.log(' Examples:')
  68. console.log()
  69. console.log(' $ peertube auth add -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD"')
  70. console.log(' $ peertube up <videoFile>')
  71. console.log(' $ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10')
  72. console.log()
  73. })
  74. .parse(process.argv)
  75. })
  76. .catch(err => console.error(err))