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