This repository has been archived by the owner on Oct 16, 2021. It is now read-only.
/
get.ts
54 lines (46 loc) · 1.52 KB
/
get.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import {Command, flags} from '@oclif/command'
import {connectToAuth0} from '../../authzero-helpers'
export default class User extends Command {
static description = 'Get profile for specificed user.'
static flags = {
help: flags.help({char: 'h'}),
user_id: flags.string({char: 'i', description: 'user_id of user', exclusive: ['username', 'email']}),
username: flags.string({char: 'u', description: 'username of user', exclusive: ['user_id', 'email']}),
email: flags.string({char: 'e', description: 'email address of user', exclusive: ['user_id', 'username']})
}
// what is this, what does it do, what are its associated semantics?
async run() {
const {flags} = this.parse(User)
// Does this belong here? Outside run()? Outside the class?
const auth0 = connectToAuth0()
if (flags.user_id) {
auth0.getUser({id: flags.user_id}, function (err: any, user: any) {
if (err) {
// do a thing
}
console.log(user)
})
} else if (flags.email) {
auth0.getUsersByEmail(flags.email, function (err: any, user: any) {
if (err) {
// do a thing
}
console.log(user)
})
} else if (flags.username) {
// Pagination settings.
const params = {
search_engine: 'v3',
per_page: 10,
page: 0,
q: 'username:' + flags.username
}
auth0.getUsers(params, function (err: any, users: any) {
if (err) {
// do a thing
}
console.log(users)
})
}
}
}