2018-09-13 14:27:44 +02:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
2019-10-21 17:13:07 +02:00
|
|
|
import { registerTSPaths } from '../helpers/register-ts-paths'
|
|
|
|
registerTSPaths()
|
|
|
|
|
2021-06-25 17:48:27 +02:00
|
|
|
import { CommandOptions, program } from 'commander'
|
2020-01-31 16:56:52 +01:00
|
|
|
import { getSettings, version } from './cli'
|
2018-09-13 14:27:44 +02:00
|
|
|
|
|
|
|
program
|
2018-10-03 14:35:35 +02:00
|
|
|
.version(version, '-v, --version')
|
2018-09-13 14:27:44 +02:00
|
|
|
.usage('[command] [options]')
|
|
|
|
|
|
|
|
/* Subcommands automatically loaded in the directory and beginning by peertube-* */
|
|
|
|
program
|
|
|
|
.command('auth [action]', 'register your accounts on remote instances to use them with other commands')
|
|
|
|
.command('upload', 'upload a video').alias('up')
|
|
|
|
.command('import-videos', 'import a video from a streaming platform').alias('import')
|
|
|
|
.command('get-access-token', 'get a peertube access token', { noHelp: true }).alias('token')
|
2019-07-19 10:37:35 +02:00
|
|
|
.command('plugins [action]', 'manage instance plugins/themes').alias('p')
|
2020-01-28 11:07:23 +01:00
|
|
|
.command('redundancy [action]', 'manage instance redundancies').alias('r')
|
2018-09-13 14:27:44 +02:00
|
|
|
|
|
|
|
/* Not Yet Implemented */
|
|
|
|
program
|
2020-01-31 16:56:52 +01:00
|
|
|
.command(
|
|
|
|
'diagnostic [action]',
|
|
|
|
'like couple therapy, but for your instance',
|
2021-06-25 17:48:27 +02:00
|
|
|
{ noHelp: true } as CommandOptions
|
2020-01-31 16:56:52 +01:00
|
|
|
).alias('d')
|
2018-09-13 14:27:44 +02:00
|
|
|
.command('admin',
|
2020-01-31 16:56:52 +01:00
|
|
|
'manage an instance where you have elevated rights',
|
2021-06-25 17:48:27 +02:00
|
|
|
{ noHelp: true } as CommandOptions
|
2020-01-31 16:56:52 +01:00
|
|
|
).alias('a')
|
2018-09-13 14:27:44 +02:00
|
|
|
|
|
|
|
// help on no command
|
|
|
|
if (!process.argv.slice(2).length) {
|
|
|
|
const logo = '░P░e░e░r░T░u░b░e░'
|
|
|
|
console.log(`
|
|
|
|
___/),.._ ` + logo + `
|
|
|
|
/' ,. ."'._
|
|
|
|
( "' '-.__"-._ ,-
|
|
|
|
\\'='='), "\\ -._-"-. -"/
|
|
|
|
/ ""/"\\,_\\,__"" _" /,-
|
|
|
|
/ / -" _/"/
|
|
|
|
/ | ._\\\\ |\\ |_.".-" /
|
|
|
|
/ | __\\)|)|),/|_." _,."
|
2021-09-10 15:43:15 +02:00
|
|
|
/ \\_." " ") | ).-""---''--
|
2018-09-13 14:27:44 +02:00
|
|
|
( "/.""7__-""''
|
|
|
|
| " ."._--._
|
|
|
|
\\ \\ (_ __ "" ".,_
|
|
|
|
\\.,. \\ "" -"".-"
|
|
|
|
".,_, (",_-,,,-".-
|
|
|
|
"'-,\\_ __,-"
|
|
|
|
",)" ")
|
|
|
|
/"\\-"
|
|
|
|
,"\\/
|
|
|
|
_,.__/"\\/_ (the CLI for red chocobos)
|
|
|
|
/ \\) "./, ".
|
2018-11-14 15:45:50 +01:00
|
|
|
--/---"---" "-) )---- by Chocobozzz et al.\n`)
|
2018-09-13 14:27:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
getSettings()
|
|
|
|
.then(settings => {
|
2019-06-13 11:09:38 +02:00
|
|
|
const state = (settings.default === undefined || settings.default === -1)
|
|
|
|
? 'no instance selected, commands will require explicit arguments'
|
|
|
|
: 'instance ' + settings.remotes[settings.default] + ' selected'
|
|
|
|
|
2018-09-13 14:27:44 +02:00
|
|
|
program
|
2021-02-03 09:33:05 +01:00
|
|
|
.addHelpText('after', '\n\n State: ' + state + '\n\n' +
|
|
|
|
' Examples:\n\n' +
|
|
|
|
' $ peertube auth add -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD"\n' +
|
2021-09-10 15:05:53 +02:00
|
|
|
' $ peertube up <videoFile>\n'
|
2021-02-03 09:33:05 +01:00
|
|
|
)
|
2018-09-13 14:27:44 +02:00
|
|
|
.parse(process.argv)
|
|
|
|
})
|
2020-01-31 16:56:52 +01:00
|
|
|
.catch(err => console.error(err))
|