Skip to content

Commit a3fd853

Browse files
authored
fix/ #53 changed syntax for executing commands through argument setting (#57)
* fix/ #53 changed syntax for executing commands through argument setting * removed console log * clean up in readme
1 parent 355f12b commit a3fd853

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- **Diagnostic cleanup**: When you close a file, its diagnostics are automatically cleared.
1111
- **Project file support**: You can feed your project file to cppcheck through the `--project` flag in the `cppcheck-official.arguments` field in the extension settings.
1212
- **Warning notes**: Display notes for warnings when those are available
13-
- **Dynamic config**: The extension supports running a script to generate arguments to pass to cppcheck. This can be done by including the command in the argument field wrapped with \${}, e.g. `--suppress=memleak:src/file1.cpp ${bash path/to/script.sh}`. The script is expected to output the argument(s) wrapped with \${}. If the script e.g. creates a project file it should print out as `${--project=path/to/projectfile.json}`. This output will be spliced into the argument string as such: `--suppress=memleak:src/file1.cpp --project=path/to/projectfile.json`.
13+
- **Dynamic config**: The extension supports running a script to generate arguments to pass to cppcheck. This can be done by including the command in the argument field wrapped with \@(), e.g. `--suppress=memleak:src/file1.cpp @(bash path/to/script.sh)`. The script is expected to output the argument(s) wrapped with \@(). If the script e.g. creates a project file it should print out as `@(--project=path/to/projectfile.json)`. This output will be spliced into the argument string as such: `--suppress=memleak:src/file1.cpp --project=path/to/projectfile.json`.
1414
## Requirements
1515

1616
**Cppcheck** must be installed on your system.

src/extension.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ export async function activate(context: vscode.ExtensionContext) {
9494
var args = config.get<string>("cppcheck-official.arguments", "");
9595
var processedArgs = '';
9696
// If argument field contains command to run script we do so here
97-
if (args.includes('${')) {
98-
const scriptCommand = args.split("${")[1].split("}")[0];
97+
if (args.includes('@(')) {
98+
const scriptCommand = args.split("@(")[1].split(")")[0];
9999
const scriptOutput = await runCommand(scriptCommand);
100100
// We expect that the script output that is to be used as arguments will be wrapped with ${}
101-
const scriptOutputTrimmed = scriptOutput.split("${")[1].split("}")[0];
102-
processedArgs = args.split("${")[0] + scriptOutputTrimmed + args.split("}")?.[1];
101+
const scriptOutputTrimmed = scriptOutput.split("@(")[1].split(")")[0];
102+
processedArgs = args.split("@(")[0] + scriptOutputTrimmed + args.split(")")?.[1];
103103
} else {
104104
processedArgs = args;
105105
}

0 commit comments

Comments
 (0)