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