peertube.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/usr/bin/env node
  2. import * as program from 'commander'
  3. import {
  4. version,
  5. getSettings
  6. } 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. /* Not Yet Implemented */
  19. program
  20. .command('plugins [action]',
  21. 'manage plugins on a local instance',
  22. { noHelp: true } as program.CommandOptions
  23. ).alias('p')
  24. .command('diagnostic [action]',
  25. 'like couple therapy, but for your instance',
  26. { noHelp: true } as program.CommandOptions
  27. ).alias('d')
  28. .command('admin',
  29. 'manage an instance where you have elevated rights',
  30. { noHelp: true } as program.CommandOptions
  31. ).alias('a')
  32. // help on no command
  33. if (!process.argv.slice(2).length) {
  34. const logo = '░P░e░e░r░T░u░b░e░'
  35. console.log(`
  36. ___/),.._ ` + logo + `
  37. /' ,. ."'._
  38. ( "' '-.__"-._ ,-
  39. \\'='='), "\\ -._-"-. -"/
  40. / ""/"\\,_\\,__"" _" /,-
  41. / / -" _/"/
  42. / | ._\\\\ |\\ |_.".-" /
  43. / | __\\)|)|),/|_." _,."
  44. / \_." " ") | ).-""---''--
  45. ( "/.""7__-""''
  46. | " ."._--._
  47. \\ \\ (_ __ "" ".,_
  48. \\.,. \\ "" -"".-"
  49. ".,_, (",_-,,,-".-
  50. "'-,\\_ __,-"
  51. ",)" ")
  52. /"\\-"
  53. ,"\\/
  54. _,.__/"\\/_ (the CLI for red chocobos)
  55. / \\) "./, ".
  56. --/---"---" "-) )---- by Chocobozzz et al.\n`)
  57. }
  58. getSettings()
  59. .then(settings => {
  60. const state = (settings.default === undefined || settings.default === -1) ?
  61. 'no instance selected, commands will require explicit arguments' :
  62. ('instance ' + settings.remotes[settings.default] + ' selected')
  63. program
  64. .on('--help', function () {
  65. console.log()
  66. console.log(' State: ' + state)
  67. console.log()
  68. console.log(' Examples:')
  69. console.log()
  70. console.log(' $ peertube auth add -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD"')
  71. console.log(' $ peertube up <videoFile>')
  72. console.log(' $ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10')
  73. console.log()
  74. })
  75. .parse(process.argv)
  76. })