]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tools/peertube.ts
Merge branch 'release/1.4.0' into develop
[github/Chocobozzz/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 .command('plugins [action]', 'manage instance plugins/themes').alias('p')
22
23 /* Not Yet Implemented */
24 program
25 .command('diagnostic [action]',
26 'like couple therapy, but for your instance',
27 { noHelp: true } as program.CommandOptions
28 ).alias('d')
29 .command('admin',
30 'manage an instance where you have elevated rights',
31 { noHelp: true } as program.CommandOptions
32 ).alias('a')
33
34 // help on no command
35 if (!process.argv.slice(2).length) {
36 const logo = '░P░e░e░r░T░u░b░e░'
37 console.log(`
38 ___/),.._ ` + logo + `
39 /' ,. ."'._
40 ( "' '-.__"-._ ,-
41 \\'='='), "\\ -._-"-. -"/
42 / ""/"\\,_\\,__"" _" /,-
43 / / -" _/"/
44 / | ._\\\\ |\\ |_.".-" /
45 / | __\\)|)|),/|_." _,."
46 / \_." " ") | ).-""---''--
47 ( "/.""7__-""''
48 | " ."._--._
49 \\ \\ (_ __ "" ".,_
50 \\.,. \\ "" -"".-"
51 ".,_, (",_-,,,-".-
52 "'-,\\_ __,-"
53 ",)" ")
54 /"\\-"
55 ,"\\/
56 _,.__/"\\/_ (the CLI for red chocobos)
57 / \\) "./, ".
58 --/---"---" "-) )---- by Chocobozzz et al.\n`)
59 }
60
61 getSettings()
62 .then(settings => {
63 const state = (settings.default === undefined || settings.default === -1)
64 ? 'no instance selected, commands will require explicit arguments'
65 : 'instance ' + settings.remotes[settings.default] + ' selected'
66
67 program
68 .on('--help', function () {
69 console.log()
70 console.log(' State: ' + state)
71 console.log()
72 console.log(' Examples:')
73 console.log()
74 console.log(' $ peertube auth add -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD"')
75 console.log(' $ peertube up <videoFile>')
76 console.log(' $ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10')
77 console.log()
78 })
79 .parse(process.argv)
80 })