Skip to content

Commit 2c17edf

Browse files
changed parameter handling in commands
1 parent bac976b commit 2c17edf

File tree

7 files changed

+18
-23
lines changed

7 files changed

+18
-23
lines changed

engine/command.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
export class Command{
22
public name: string;
3-
public parameters: string;
3+
public parameterString: string;
4+
5+
get parameters(): any[] {
6+
let params = JSON.parse("[" + this.parameterString + "]");
7+
return params;
8+
}
49
}

engine/parser.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ stepline
5252
= !"--" string __ { return { "stepline": text()}; }
5353

5454
string "string"
55-
= [a-zA-Z0-9.(),;:/-_- ]+ { return text(); }
55+
= [a-zA-Z0-9.(),;:/-_-" ]+ { return text(); }
5656

5757
_ "whitespace"
5858
= [ \t]*

engine/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class Parser {
5454
let result = re.exec(line);
5555
let retVal = new Command();
5656
retVal.name = result[1].trim();
57-
retVal.parameters = result[2];
57+
retVal.parameterString = result[2];
5858
return retVal;
5959
}
6060

engine/runner.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,4 @@ export abstract class Runner {
109109
fs.mkdirSync(path, { recursive: true });
110110
return path;
111111
}
112-
113-
protected parseInputParameters(parameterString: string) {
114-
let regex = /(((?<array>\[[^\]]+\])|(?<string>[^[,]+))\s*,?\s*)/mg;
115-
let parameters = [];
116-
for (let matches = regex.exec(parameterString); matches != null; matches = regex.exec(parameterString)) {
117-
parameters.push(matches[2]);
118-
}
119-
return parameters;
120-
}
121112
}

playbooks/cobigen-cli/index.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ More information about CobiGen on https://devonfw.com/website/pages/docs/master-
1010
To use the cobigen cli you first have to install the devonfw ide. You will find more information about devonfw on https://devonfw.com/website/pages/welcome/welcome.html.
1111
[step]
1212
--
13-
installDevonfwIde([java,mvn])
13+
installDevonfwIde(["java","mvn"])
1414
--
1515

1616
Now, you have to download cobigen
@@ -20,9 +20,9 @@ installCobiGen()
2020
--
2121

2222
====
23-
The CobiGen plugin for VS Code is already installed. We will use it to generate code from one single java class based on existing templates.
23+
CobiGen is integrated via plugin in the VS Code IDE. We will use it to generate code from one single java class based on existing templates.
2424
[step]
2525
--
26-
cobiGenJava(Test.java,[1,2,3,4])
26+
cobiGenJava("Test.java",[1,2,3,4])
2727
--
28-
====
28+
====

runners/console/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ export class Console extends Runner {
1616
let settingsDir = this.createFolder(path.join(this.getWorkingDirectory(), "devonfw-settings"), true);
1717
this.executeCommandSync("git clone https://github.com/devonfw/ide-settings.git settings", settingsDir, result);
1818

19-
let params = command.parameters.replace(/\[/, "").replace("\]", "").replace(/,/, " ").trim();
20-
let tools = "DEVON_IDE_TOOLS=(" + params + ")";
19+
let tools = "DEVON_IDE_TOOLS=(" + command.parameters[0].join(" ") + ")";
2120
fs.writeFileSync(path.join(settingsDir, "settings", "devon.properties"), tools);
2221
fs.renameSync(path.join(settingsDir, "settings"), path.join(settingsDir, "settings.git"));
2322
this.executeCommandSync("git add -A && git config user.email \"devonfw\" && git config user.name \"devonfw\" && git commit -m \"devonfw\"", path.join(settingsDir, "settings.git"), result);
@@ -37,7 +36,7 @@ export class Console extends Runner {
3736
}
3837

3938
async assertInstallDevonfwIde(step: Step, command: Command, result: RunResult) {
40-
let installedTools = command.parameters.replace(/\[/, "").replace("\]", "").replace(/mvn/, "maven").split(",");
39+
let installedTools = command.parameters[0];
4140

4241
let assert = new Assertions()
4342
.noErrorCode(result)
@@ -46,6 +45,7 @@ export class Console extends Runner {
4645
.directoryExits(path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main"));
4746

4847
for(let i = 0; i < installedTools.length; i++) {
48+
if(installedTools[i] == "mvn") installedTools[i] = "maven";
4949
assert.directoryExits(path.join(this.getWorkingDirectory(), "devonfw", "software", installedTools[i]));
5050
}
5151
}

runners/katacoda/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ export class Katacoda extends Runner {
6666
}
6767

6868
runInstallDevonfwIde(step: Step, command: Command): RunResult {
69-
let params = this.parseInputParameters(command.parameters);
70-
let tools = params[0].replace(/\[/, "").replace(/\]/g, "").replace(/,/, " ").replace(/vscode/,"").replace(/eclipse/, "").trim();
69+
let tools = command.parameters[0].join(" ").replace(/vscode/,"").replace(/eclipse/, "").trim();
7170

7271
// create script to download devonfw ide settings
7372
this.renderTemplate(path.join("scripts", "cloneDevonfwIdeSettings.sh"), path.join(this.setupDir, "cloneDevonfwIdeSettings.sh"), { tools: tools, cloneDir: "/root/devonfw-settings/"});
@@ -96,8 +95,8 @@ export class Katacoda extends Runner {
9695
}
9796

9897
runCobiGenJava(step: Step, command: Command): RunResult {
99-
let params = this.parseInputParameters(command.parameters)
100-
let cobiGenTemplates = params[1].replace(/\[/, "").replace(/\]/g, "");
98+
let params = command.parameters;
99+
let cobiGenTemplates = params[1].join(",");
101100

102101
this.renderTemplate(path.join("scripts", "installCobiGenPlugin.sh"), path.join(this.setupDir, "installCobiGenPlugin.sh"), { vsixFile: "cobigen-0.0.1.vsix", pluginName: "cobigen" });
103102
this.setupScripts.push({

0 commit comments

Comments
 (0)