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

Class __nomethod__Command

cli/commands/__nomethod__.js:46–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44const lib = require('lib');
45
46class __nomethod__Command extends Command {
47
48 constructor() {
49
50 super('*');
51
52 }
53
54 help() {
55
56 return {
57 description: 'Runs an Autocode function, i.e. "lib user.service[@env]" (remote) or "lib ." (local)',
58 flags: {
59 b: 'Execute as a Background Function',
60 d: 'Specify debug mode (prints Gateway logs locally, response logs remotely)',
61 t: 'Specify an Identity Token to use manually',
62 x: 'Unauthenticated - Execute without a token (overrides active token and -t flag)',
63 i: 'Specify information mode (prints tar packing and execution request progress)',
64 h: 'Specify headers in format key1 value1 key2 value2 ...',
65 a: 'Specify header "Authorization: Bearer [token]" token'
66 },
67 vflags: {
68 '*': 'all verbose flags converted to named keyword parameters'
69 }
70 };
71
72 }
73
74 run (params, callback) {
75
76 let debug = !!params.flags.d;
77 let infoMode = !!params.flags.i;
78 let isLocal = false;
79 let gateway;
80
81 if (params.name.indexOf('.') === -1) {
82 if (params.name.indexOf('/') > -1) {
83 let names = params.name.split('/');
84 if (names[1].indexOf('@') > -1) {
85 names[1] = names[1].split('@');
86 if (names[1].length > 1) {
87 names[1][1] = names[1][1] && `[@${names[1][1]}]`;
88 }
89 names[1] = names[1].slice(0, 2).join('');
90 }
91 return callback(new Error(`Deprecated service path usage, please try \`lib ${names.join('.')}\` instead`));
92 }
93 return callback(new Error(`Command "${params.name}" does not exist.`));
94 } else if (params.name[0] === '.') {
95 isLocal = true;
96 let pkg;
97 let env;
98 try {
99 pkg = serviceConfig.get()
100 } catch (e) {
101 if (!config.workspace()) {
102 return callback(new Error([
103 'You have not set up a Autocode workspace yet.',

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected