]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tools/peertube.ts
Prepare changelog
[github/Chocobozzz/PeerTube.git] / server / tools / peertube.ts
1 #!/usr/bin/env node
2
3 /* eslint-disable no-useless-escape */
4
5 import { registerTSPaths } from '../helpers/register-ts-paths'
6 registerTSPaths()
7
8 import * as program from 'commander'
9 import { getSettings, version } from './cli'
10
11 program
12 .version(version, '-v, --version')
13 .usage('[command] [options]')
14
15 /* Subcommands automatically loaded in the directory and beginning by peertube-* */
16 program
17 .command('auth [action]', 'register your accounts on remote instances to use them with other commands')
18 .command('upload', 'upload a video').alias('up')
19 .command('import-videos', 'import a video from a streaming platform').alias('import')
20 .command('get-access-token', 'get a peertube access token', { noHelp: true }).alias('token')
21 .command('watch', 'watch a video in the terminal ✩°。⋆').alias('w')
22 .command('repl', 'initiate a REPL to access internals')
23 .command('plugins [action]', 'manage instance plugins/themes').alias('p')
24 .command('redundancy [action]', 'manage instance redundancies').alias('r')
25
26 /* Not Yet Implemented */
27 program
28 .command(
29 '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 })
85 .catch(err => console.error(err))