]>
Commit | Line | Data |
---|---|---|
2aaa1a3f C |
1 | import { registerTSPaths } from '../helpers/register-ts-paths' |
2 | registerTSPaths() | |
3 | ||
12152aa0 | 4 | import { program } from 'commander' |
d0a0fa42 | 5 | import { assignToken, buildServer } from './cli' |
8df87ce7 C |
6 | |
7 | program | |
8 | .option('-u, --url <url>', 'Server url') | |
9 | .option('-n, --username <username>', 'Username') | |
10 | .option('-p, --password <token>', 'Password') | |
11 | .parse(process.argv) | |
12 | ||
ba5a8d89 C |
13 | const options = program.opts() |
14 | ||
8df87ce7 | 15 | if ( |
ba5a8d89 C |
16 | !options.url || |
17 | !options.username || | |
18 | !options.password | |
8df87ce7 | 19 | ) { |
ba5a8d89 C |
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.') | |
1a12f66d | 23 | |
8704acf4 | 24 | process.exit(-1) |
8df87ce7 C |
25 | } |
26 | ||
d0a0fa42 C |
27 | const server = buildServer(options.url) |
28 | ||
29 | assignToken(server, options.username, options.password) | |
30 | .then(() => { | |
31 | console.log(server.accessToken) | |
8df87ce7 C |
32 | process.exit(0) |
33 | }) | |
34 | .catch(err => { | |
35 | console.error(err) | |
36 | process.exit(-1) | |
37 | }) |