aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/peertube.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2018-09-13 14:27:44 +0200
committerRigel Kent <sendmemail@rigelk.eu>2018-09-14 11:08:55 +0200
commit8704acf49efc770d73bf07c10468ed8c74d28a83 (patch)
treeffd46289fcf9a13ac4412b167e9f71dfb35753c5 /server/tools/peertube.ts
parent1d9d9cfdcf3983e3fd89026bc4b5633a8abf5752 (diff)
downloadPeerTube-8704acf49efc770d73bf07c10468ed8c74d28a83.tar.gz
PeerTube-8704acf49efc770d73bf07c10468ed8c74d28a83.tar.zst
PeerTube-8704acf49efc770d73bf07c10468ed8c74d28a83.zip
one cli to unite them all
Ash nazg thrakatulûk agh burzum-ishi krimpatul - refactor import-videos to use the youtubeDL helper - add very basic tests for the cli
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 })