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