]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tools/peertube.ts
Use typescript paths in cli scripts too
[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
26 /* Not Yet Implemented */
27 program
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
70 program
71 .on('--help', function () {
72 console.log()
73 console.log(' State: ' + state)
74 console.log()
75 console.log(' Examples:')
76 console.log()
77 console.log(' $ peertube auth add -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD"')
78 console.log(' $ peertube up <videoFile>')
79 console.log(' $ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10')
80 console.log()
81 })
82 .parse(process.argv)
83 })