aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/peertube.ts
blob: 1d3158044c7f33f171615d123ea72dfdacbaa019 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env node

import { CommandOptions, program } from 'commander'
import { getSettings, version } from './cli'

program
  .version(version, '-v, --version')
  .usage('[command] [options]')

/* Subcommands automatically loaded in the directory and beginning by peertube-* */
program
  .command('auth [action]', 'register your accounts on remote instances to use them with other commands')
  .command('upload', 'upload a video').alias('up')
  .command('import-videos', 'import a video from a streaming platform').alias('import')
  .command('get-access-token', 'get a peertube access token', { noHelp: true }).alias('token')
  .command('plugins [action]', 'manage instance plugins/themes').alias('p')
  .command('redundancy [action]', 'manage instance redundancies').alias('r')

/* Not Yet Implemented */
program
  .command(
    'diagnostic [action]',
    'like couple therapy, but for your instance',
    { noHelp: true } as CommandOptions
  ).alias('d')
  .command('admin',
    'manage an instance where you have elevated rights',
    { noHelp: true } as CommandOptions
  ).alias('a')

// help on no command
if (!process.argv.slice(2).length) {
  const logo = '░P░e░e░r░T░u░b░e░'
  console.log(`
  ___/),.._                           ` + logo + `
/'   ,.   ."'._
(     "'   '-.__"-._             ,-
\\'='='),  "\\ -._-"-.          -"/
      / ""/"\\,_\\,__""       _" /,-
     /   /                -" _/"/
    /   |    ._\\\\ |\\  |_.".-"  /
   /    |   __\\)|)|),/|_." _,."
  /     \\_."   " ") | ).-""---''--
 (                  "/.""7__-""''
 |                   " ."._--._
 \\       \\ (_    __   ""   ".,_
  \\.,.    \\  ""   -"".-"
   ".,_,  (",_-,,,-".-
       "'-,\\_   __,-"
             ",)" ")
              /"\\-"
            ,"\\/
      _,.__/"\\/_                     (the CLI for red chocobos)
     / \\) "./,  ".
  --/---"---" "-) )---- by Chocobozzz et al.\n`)
}

getSettings()
  .then(settings => {
    const state = (settings.default === undefined || settings.default === -1)
      ? 'no instance selected, commands will require explicit arguments'
      : 'instance ' + settings.remotes[settings.default] + ' selected'

    program
      .addHelpText('after', '\n\n  State: ' + state + '\n\n' +
        '  Examples:\n\n' +
        '    $ peertube auth add -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD"\n' +
        '    $ peertube up <videoFile>\n'
      )
      .parse(process.argv)
  })
  .catch(err => console.error(err))