aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/peertube.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-20 16:24:49 +0200
committerGitHub <noreply@github.com>2018-09-20 16:24:49 +0200
commitdc27668fceb1d0270c391c93c3bbc95d12e83218 (patch)
treece6621597505f9518cfdf0981977d097c63f9fad /server/tools/peertube.ts
parent6247b2057b792cea155a1abd9788c363ae7d2cc2 (diff)
parent0491173a61aed66205c017e0d7e0503ea316c144 (diff)
downloadPeerTube-dc27668fceb1d0270c391c93c3bbc95d12e83218.tar.gz
PeerTube-dc27668fceb1d0270c391c93c3bbc95d12e83218.tar.zst
PeerTube-dc27668fceb1d0270c391c93c3bbc95d12e83218.zip
Merge pull request #941 from rigelk/cli-wrapper
adding cli wrapper
Diffstat (limited to 'server/tools/peertube.ts')
-rwxr-xr-xserver/tools/peertube.ts81
1 files changed, 81 insertions, 0 deletions
diff --git a/server/tools/peertube.ts b/server/tools/peertube.ts
new file mode 100755
index 000000000..7441161b1
--- /dev/null
+++ b/server/tools/peertube.ts
@@ -0,0 +1,81 @@
1#!/usr/bin/env node
2
3import * as program from 'commander'
4import {
5 version,
6 getSettings
7} from './cli'
8
9program
10 .version(version(), '-v, --version')
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')
20
21/* Not Yet Implemented */
22program
23 .command('plugins [action]',
24 'manage plugins on a local instance',
25 { noHelp: true } as program.CommandOptions
26 ).alias('p')
27 .command('diagnostic [action]',
28 'like couple therapy, but for your instance',
29 { noHelp: true } as program.CommandOptions
30 ).alias('d')
31 .command('admin',
32 'manage an instance where you have elevated rights',
33 { noHelp: true } as program.CommandOptions
34 ).alias('a')
35
36// help on no command
37if (!process.argv.slice(2).length) {
38 const logo = '░P░e░e░r░T░u░b░e░'
39 console.log(`
40 ___/),.._ ` + logo + `
41/' ,. ."'._
42( "' '-.__"-._ ,-
43\\'='='), "\\ -._-"-. -"/
44 / ""/"\\,_\\,__"" _" /,-
45 / / -" _/"/
46 / | ._\\\\ |\\ |_.".-" /
47 / | __\\)|)|),/|_." _,."
48 / \_." " ") | ).-""---''--
49 ( "/.""7__-""''
50 | " ."._--._
51 \\ \\ (_ __ "" ".,_
52 \\.,. \\ "" -"".-"
53 ".,_, (",_-,,,-".-
54 "'-,\\_ __,-"
55 ",)" ")
56 /"\\-"
57 ,"\\/
58 _,.__/"\\/_ (the CLI for red chocobos)
59 / \\) "./, ".
60 --/---"---" "-) )---- by Chocobozzz et al.`)
61}
62
63getSettings()
64 .then(settings => {
65 const state = (settings.default === -1) ?
66 'no instance selected, commands will require explicit arguments' :
67 ('instance ' + settings.remotes[settings.default] + ' selected')
68 program
69 .on('--help', function () {
70 console.log()
71 console.log(' State: ' + state)
72 console.log()
73 console.log(' Examples:')
74 console.log()
75 console.log(' $ peertube auth add -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD"')
76 console.log(' $ peertube up <videoFile>')
77 console.log(' $ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10')
78 console.log()
79 })
80 .parse(process.argv)
81 })