Skip to content

Commit bcb2d87

Browse files
committed
feat: added CIM tag autocomplete to tags.conf
Addresses issue #25
1 parent a737719 commit bcb2d87

File tree

3 files changed

+497
-3
lines changed

3 files changed

+497
-3
lines changed

out/extension.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ function handleSplunkFile(context) {
251251
if(specConfigs.hasOwnProperty(currentDocument)) {
252252
specConfig = specConfigs[currentDocument];
253253
} else {
254-
specConfig = splunkSpec.getSpecConfig(specFilePath);
254+
specConfig = splunkSpec.getSpecConfig(context.extensionPath, specFilePath);
255255

256256
// Register Stanza completion items for this spec
257257
context.subscriptions.push(provideStanzaCompletionItems(specConfig));
@@ -398,6 +398,9 @@ function provideSettingCompletionItems(specConfig, trimWhitespace) {
398398
}
399399

400400
// Convert <enabled|disabled> to ${1|enabled,disabled|}
401+
if(settingSnippet.indexOf("${1:<enabled|disabled>}") > -1) {
402+
settingSnippet = settingSnippet.replace("${1:<enabled|disabled>}", "${1|enabled,disabled|}")
403+
}
401404
if(settingSnippet.indexOf("${2:<enabled|disabled>}") > -1) {
402405
settingSnippet = settingSnippet.replace("${2:<enabled|disabled>}", "${2|enabled,disabled|}")
403406
}

out/spec.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,21 @@ const stanzaTypes = {
5555
stanzas: []
5656
}
5757
*/
58-
function getSpecConfig(specFilePath) {
58+
function getSpecConfig(extensionPath, specFilePath) {
5959

6060
let specFileName = path.parse(specFilePath).base;
61-
6261
let specFileContent = fs.readFileSync(specFilePath, "utf-8");
62+
63+
// Special case for tags.conf.spec
64+
// Append CIM tag options
65+
// See https://github.com/splunk/vscode-extension-splunk/issues/25
66+
if(specFileName == "tags.conf.spec") {
67+
let tagCIMpath = path.join(extensionPath, "spec_files", "tags.conf.cim.spec")
68+
let cimFileContent = fs.readFileSync(tagCIMpath, "utf-8");
69+
specFileContent = specFileContent + cimFileContent
70+
}
71+
72+
6373
let specConfig = parseSpecConfig(specFileContent, specFileName);
6474

6575
// Special case for inputs.conf.spec

0 commit comments

Comments
 (0)