]>
Commit | Line | Data |
---|---|---|
8df87ce7 | 1 | import * as program from 'commander' |
8df87ce7 C |
2 | |
3 | import { | |
4 | getClient, | |
eec63bbc | 5 | serverLogin |
a7fea183 | 6 | } from '../tests/utils/index' |
8df87ce7 C |
7 | |
8 | program | |
9 | .option('-u, --url <url>', 'Server url') | |
10 | .option('-n, --username <username>', 'Username') | |
11 | .option('-p, --password <token>', 'Password') | |
12 | .parse(process.argv) | |
13 | ||
14 | if ( | |
15 | !program['url'] || | |
16 | !program['username'] || | |
17 | !program['password'] | |
18 | ) { | |
19 | throw new Error('All arguments are required.') | |
20 | } | |
21 | ||
22 | const server = { | |
23 | url: program['url'], | |
24 | user: { | |
25 | username: program['username'], | |
26 | password: program['password'] | |
27 | }, | |
28 | client: { | |
29 | id: null, | |
30 | secret: null | |
31 | } | |
32 | } | |
33 | ||
34 | getClient(program.url) | |
35 | .then(res => { | |
36 | server.client.id = res.body.client_id | |
37 | server.client.secret = res.body.client_secret | |
38 | ||
eec63bbc | 39 | return serverLogin(server) |
8df87ce7 C |
40 | }) |
41 | .then(accessToken => { | |
42 | console.log(accessToken) | |
43 | process.exit(0) | |
44 | }) | |
45 | .catch(err => { | |
46 | console.error(err) | |
47 | process.exit(-1) | |
48 | }) |