2
1

peertube.ts 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/usr/bin/env node
  2. import { registerTSPaths } from '../helpers/register-ts-paths'
  3. registerTSPaths()
  4. import * as program from 'commander'
  5. import {
  6. version,
  7. getSettings
  8. } from './cli'
  9. program
  10. .version(version, '-v, --version')
  11. .usage('[command] [options]')
  12. /* Subcommands automatically loaded in the directory and beginning by peertube-* */
  13. program
  14. .command('auth [action]', 'register your accounts on remote instances to use them with other commands')
  15. .command('upload', 'upload a video').alias('up')
  16. .command('import-videos', 'import a video from a streaming platform').alias('import')
  17. .command('get-access-token', 'get a peertube access token', { noHelp: true }).alias('token')
  18. .command('watch', 'watch a video in the terminal ✩°。⋆').alias('w')
  19. .command('repl', 'initiate a REPL to access internals')
  20. .command('plugins [action]', 'manage instance plugins/themes').alias('p')
  21. /* Not Yet Implemented */
  22. program
  23. .command('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. })