Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit e9287a9

Browse files
committed
bug fix for quote parsing of command line
Fixes #728
1 parent 8e8a499 commit e9287a9

File tree

5 files changed

+75
-2
lines changed

5 files changed

+75
-2
lines changed

app/content/js/repl.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,15 @@ const split = (str, removeOuterQuotes=true) => {
472472
continue
473473
}
474474

475+
const last = stack.length > 0 && stack[stack.length - 1]
476+
477+
if (char === '{') {
478+
stack.push(char)
479+
} else if (char === '}' && last === '{') {
480+
stack.pop()
481+
}
482+
475483
if (char === '\'' || char === '"') {
476-
const last = stack.length > 0 && stack[stack.length - 1]
477484

478485
if (char === last) {
479486
// found matching close quote

app/plugins/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"license": "ISC",
1212
"dependencies": {
1313
"archiver": "^1.3.0",
14+
"debug": "^3.1.0",
1415
"htmlparser2": "^3.9.2",
1516
"inquirer": "^3.3.0",
1617
"js-beautify": "1.6.14",

app/plugins/ui/commands/openwhisk-core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ const handleKeyValuePairAsArray = key => (M, idx, argv, type) => {
258258
while (!argv[idx].endsWith(startQuote)) {
259259
paramValue = `${paramValue} ${argv[++idx]}`
260260
}
261-
paramValue = paramValue.replace(new RegExp(startQuote, 'g'), '')
261+
//paramValue = paramValue.replace(new RegExp(startQuote, 'g'), '')
262262
}
263263

264264
if (paramValue.charAt(0) === '@') {

tests/lib/ui.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ selectors.SIDECAR_PACKAGE_NAME_TITLE = `${selectors.SIDECAR} .sidecar-header-nam
3939
selectors.SIDECAR_CONTENT = `${selectors.SIDECAR} .sidecar-content`,
4040
selectors.SIDECAR_WEB_ACTION_URL = `${selectors.SIDECAR} .sidecar-header .entity-web-export-url.has-url`
4141
selectors.SIDECAR_ACTION_SOURCE = `${selectors.SIDECAR_CONTENT} .action-content .action-source`,
42+
selectors.SIDECAR_PACKAGE_PARAMETERS = `${selectors.SIDECAR_CONTENT} .package-content .package-source`,
4243
selectors.SIDECAR_ACTIVATION_RESULT = `${selectors.SIDECAR_CONTENT} .activation-result`,
4344
selectors.SIDECAR_ACTIVATION_ID = `${selectors.SIDECAR} .sidecar-header .activation-id`,
4445
selectors.SIDECAR_RULE_CANVAS = `${selectors.SIDECAR} .rule-components`
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright 2018 IBM Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
const common = require('../../../lib/common'),
18+
openwhisk = require('../../../lib/openwhisk'),
19+
ui = require('../../../lib/ui'),
20+
assert = require('assert'),
21+
keys = ui.keys,
22+
cli = ui.cli,
23+
sidecar = ui.sidecar,
24+
actionName = 'foo'
25+
26+
describe('parameter parsing with quotes', function() {
27+
before(common.before(this))
28+
after(common.after(this))
29+
30+
it('should have an active repl', () => cli.waitForRepl(this.app))
31+
32+
const createWith = params => {
33+
return it(`should create package with -p creds ${params}`, () => cli.do(`package update ppp -p creds ${params}`, this.app)
34+
.then(cli.expectOK)
35+
.then(sidecar.expectOpen)
36+
.then(sidecar.expectShowing('ppp'))
37+
.catch(common.oops(this)))
38+
}
39+
40+
const expectParams = params => {
41+
return it('should show parameters', () => cli.do('params', this.app)
42+
.then(cli.expectOK)
43+
.then(sidecar.expectOpen)
44+
.then(sidecar.expectShowing('ppp'))
45+
.then(app => app.client.getText(`${ui.selectors.SIDECAR_PACKAGE_PARAMETERS}`))
46+
.then(ui.expectStruct(params))
47+
.catch(common.oops(this)))
48+
}
49+
50+
createWith(`'"foo" "bar"'`)
51+
expectParams({creds:'"foo" "bar"'})
52+
53+
createWith(`{"foo":"bar"}`)
54+
expectParams({creds:{foo:"bar"}})
55+
56+
createWith(`{"'foo'":"bar"}`)
57+
expectParams({creds:{"'foo'":"bar"}})
58+
59+
createWith(`'{"foo": "bar"}'`)
60+
expectParams({creds:{foo:"bar"}})
61+
62+
createWith(`{"foo":{"bar":"baz"}}`)
63+
expectParams({creds:{foo:{bar:"baz"}}})
64+
})

0 commit comments

Comments
 (0)