]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/tools/peertube-get-access-token.ts
Fix live tests
[github/Chocobozzz/PeerTube.git] / server / tools / peertube-get-access-token.ts
... / ...
CommitLineData
1import { registerTSPaths } from '../helpers/register-ts-paths'
2registerTSPaths()
3
4import { program } from 'commander'
5import { assignToken, buildServer } from './cli'
6
7program
8 .option('-u, --url <url>', 'Server url')
9 .option('-n, --username <username>', 'Username')
10 .option('-p, --password <token>', 'Password')
11 .parse(process.argv)
12
13const options = program.opts()
14
15if (
16 !options.url ||
17 !options.username ||
18 !options.password
19) {
20 if (!options.url) console.error('--url field is required.')
21 if (!options.username) console.error('--username field is required.')
22 if (!options.password) console.error('--password field is required.')
23
24 process.exit(-1)
25}
26
27const server = buildServer(options.url)
28
29assignToken(server, options.username, options.password)
30 .then(() => {
31 console.log(server.accessToken)
32 process.exit(0)
33 })
34 .catch(err => {
35 console.error(err)
36 process.exit(-1)
37 })