]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tools/peertube.ts
Add more e2e tests
[github/Chocobozzz/PeerTube.git] / server / tools / peertube.ts
CommitLineData
8704acf4
RK
1#!/usr/bin/env node
2
3import * as program from 'commander'
4import {
5 version,
6 getSettings
7} from './cli'
8
9program
499d9015 10 .version(version, '-v, --version')
8704acf4
RK
11 .usage('[command] [options]')
12
13/* Subcommands automatically loaded in the directory and beginning by peertube-* */
14program
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')
c141f68b 20 .command('repl', 'initiate a REPL to access internals')
8704acf4
RK
21
22/* Not Yet Implemented */
23program
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
38if (!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 / \\) "./, ".
e5cb43e0 61 --/---"---" "-) )---- by Chocobozzz et al.\n`)
8704acf4
RK
62}
63
64getSettings()
65 .then(settings => {
1a12f66d
C
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
8704acf4
RK
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 })