diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2018-09-13 14:27:44 +0200 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2018-09-14 11:08:55 +0200 |
commit | 8704acf49efc770d73bf07c10468ed8c74d28a83 (patch) | |
tree | ffd46289fcf9a13ac4412b167e9f71dfb35753c5 /server/tools/get-access-token.ts | |
parent | 1d9d9cfdcf3983e3fd89026bc4b5633a8abf5752 (diff) | |
download | PeerTube-8704acf49efc770d73bf07c10468ed8c74d28a83.tar.gz PeerTube-8704acf49efc770d73bf07c10468ed8c74d28a83.tar.zst PeerTube-8704acf49efc770d73bf07c10468ed8c74d28a83.zip |
one cli to unite them all
Ash nazg thrakatulûk agh burzum-ishi krimpatul
- refactor import-videos to use the youtubeDL helper
- add very basic tests for the cli
Diffstat (limited to 'server/tools/get-access-token.ts')
-rw-r--r-- | server/tools/get-access-token.ts | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/server/tools/get-access-token.ts b/server/tools/get-access-token.ts deleted file mode 100644 index d86c84c8d..000000000 --- a/server/tools/get-access-token.ts +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | import * as program from 'commander' | ||
2 | |||
3 | import { | ||
4 | getClient, | ||
5 | serverLogin, | ||
6 | Server, | ||
7 | Client, | ||
8 | User | ||
9 | } from '../tests/utils/index' | ||
10 | |||
11 | program | ||
12 | .option('-u, --url <url>', 'Server url') | ||
13 | .option('-n, --username <username>', 'Username') | ||
14 | .option('-p, --password <token>', 'Password') | ||
15 | .parse(process.argv) | ||
16 | |||
17 | if ( | ||
18 | !program['url'] || | ||
19 | !program['username'] || | ||
20 | !program['password'] | ||
21 | ) { | ||
22 | throw new Error('All arguments are required.') | ||
23 | } | ||
24 | |||
25 | getClient(program.url) | ||
26 | .then(res => { | ||
27 | const server = { | ||
28 | url: program['url'], | ||
29 | user: { | ||
30 | username: program['username'], | ||
31 | password: program['password'] | ||
32 | } as User, | ||
33 | client: { | ||
34 | id: res.body.client_id as string, | ||
35 | secret: res.body.client_secret as string | ||
36 | } as Client | ||
37 | } as Server | ||
38 | |||
39 | return serverLogin(server) | ||
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 | }) | ||