Skip to content

Commit b7c96dc

Browse files
committed
Support sending in headers for calling lib functions
1 parent c974700 commit b7c96dc

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

cli/commands/__nomethod__.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ class __nomethod__Command extends Command {
6060
d: 'Specify debug mode (prints Gateway logs locally, response logs remotely)',
6161
t: 'Specify an Identity Token to use manually',
6262
x: 'Unauthenticated - Execute without a token (overrides active token and -t flag)',
63-
i: 'Specify information mode (prints tar packing and execution request progress)'
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'
6466
},
6567
vflags: {
6668
'*': 'all verbose flags converted to named keyword parameters'
@@ -198,6 +200,22 @@ class __nomethod__Command extends Command {
198200
let key = keys[i];
199201
kwargs[key] = await parseFileFromArg(params.vflags[key].join(' '), infoMode);
200202
}
203+
if (params.flags.a) {
204+
kwargs['__headers'] = kwargs['__headers'] || {};
205+
kwargs['__headers']['Authorization'] = `Bearer ${params.flags.a.join(' ')}`;
206+
}
207+
if (params.flags.h) {
208+
let headerPairs = params.flags.h;
209+
while (headerPairs.length) {
210+
kwargs['__headers'] = kwargs['__headers'] || {};
211+
let key = (headerPairs.shift() || '')
212+
.split('-')
213+
.map(str => str[0].toUpperCase() + str.slice(1))
214+
.join('-');
215+
let value = headerPairs.shift() || '';
216+
kwargs['__headers'][key] = value;
217+
}
218+
}
201219
};
202220

203221
kwargsCheck().catch(e => callback(e)).then(() => {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lib.cli",
3-
"version": "5.6.1",
3+
"version": "5.7.0",
44
"description": "Command Line tools for Autocode - autocode.com",
55
"main": "index.js",
66
"scripts": {
@@ -40,7 +40,7 @@
4040
"cmnd": "~0.3.0",
4141
"functionscript": "^2.10.5",
4242
"inquirer": "^7.3.3",
43-
"lib": "^5.0.1",
43+
"lib": "^5.1.0",
4444
"minimatch": "^3.0.4",
4545
"ncp": "^2.0.0",
4646
"pusher-js": "^7.0.2",

0 commit comments

Comments
 (0)