MCPcopy Create free account
hub / github.com/acode/cli / TokensListCommand

Class TokensListCommand

cli/commands/tokens/list.js:11–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9const tabler = require('../../tabler.js');
10
11class TokensListCommand extends Command {
12
13 constructor() {
14 super('tokens', 'list');
15 }
16
17 help() {
18 return {
19 description: 'Lists your remotely generated Identity Tokens (Authentication)',
20 flags: {
21 's': 'Silent mode - do not display information',
22 'a': 'All - show invalidated tokens as well'
23 },
24 vflags: {
25 'silent': 'Silent mode - do not display information',
26 'all': 'All - show invalidated tokens as well'
27 }
28 };
29 }
30
31 run(params, callback) {
32
33 let activeToken = config.get('ACTIVE_LIBRARY_TOKEN');
34
35 let host = params.flags.h ? params.flags.h[0] : 'https://api.autocode.com';
36 let port = params.flags.p && params.flags.p[0];
37 let silent = !!(params.flags.s || params.vflags.silent);
38 let all = !!(params.flags.a || params.vflags.all);
39
40 let resource = new APIResource(host, port);
41 let reqParams = {};
42 all && (reqParams.all = true);
43
44 resource.authorize(config.get('ACCESS_TOKEN'));
45 resource.request('/v1/library_tokens').index(reqParams, (err, response) => {
46
47 if (err) {
48 return callback(err);
49 }
50
51 let tokens = (response && response.data) || [];
52
53 if (!tokens.length) {
54 console.log();
55 console.log(chalk.bold.red('Oops!'));
56 console.log();
57 console.log(`It doesn't look like you have any remotely generated Identity Tokens.`);
58 console.log(`This usually means you've removed them.`);
59 console.log();
60 console.log(`Try typing `);
61 console.log(`\t${chalk.bold('lib tokens:create')}`);
62 console.log();
63 console.log(`To create a new Identity Token (remote).`);
64 console.log();
65 return callback(new Error('No remotely generated tokens.'));
66 }
67
68 if (!silent) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected