Support enabling/disabling boolean options (#144)

Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
Sanjula Ganepola
2025-01-19 13:08:52 -05:00
committed by GitHub
parent 375ca40178
commit 69ea69182c
2 changed files with 46 additions and 12 deletions

View File

@@ -368,6 +368,7 @@ export class Act {
}, },
{ {
label: Option.ActionOfflineMode, label: Option.ActionOfflineMode,
description: 'false',
detail: 'If action contents exists, it will not be fetched and pulled again. If this is turned on, it will turn off force pull.' detail: 'If action contents exists, it will not be fetched and pulled again. If this is turned on, it will turn off force pull.'
}, },
{ {
@@ -392,6 +393,7 @@ export class Act {
}, },
{ {
label: Option.Bind, label: Option.Bind,
description: 'false',
detail: 'Bind working directory to container, rather than copy.' detail: 'Bind working directory to container, rather than copy.'
}, },
{ {
@@ -441,6 +443,7 @@ export class Act {
}, },
{ {
label: Option.DetectEvent, label: Option.DetectEvent,
description: 'false',
detail: 'Use first event type from workflow as event that triggered the workflow.' detail: 'Use first event type from workflow as event that triggered the workflow.'
}, },
{ {
@@ -450,6 +453,7 @@ export class Act {
}, },
{ {
label: Option.DryRun, label: Option.DryRun,
description: 'false',
detail: 'Disable container creation and validate only workflow correctness.' detail: 'Disable container creation and validate only workflow correctness.'
}, },
{ {
@@ -459,10 +463,12 @@ export class Act {
}, },
{ {
label: Option.InsecureSecrets, label: Option.InsecureSecrets,
description: 'false',
detail: 'Show secrets while printing logs (NOT RECOMMENDED!).' detail: 'Show secrets while printing logs (NOT RECOMMENDED!).'
}, },
{ {
label: Option.Json, label: Option.Json,
description: 'false',
detail: 'Output logs in json format.' detail: 'Output logs in json format.'
}, },
{ {
@@ -472,6 +478,7 @@ export class Act {
}, },
{ {
label: Option.LogPrefixJobId, label: Option.LogPrefixJobId,
description: 'false',
detail: 'Output the job id within non-json logs instead of the entire name.' detail: 'Output the job id within non-json logs instead of the entire name.'
}, },
{ {
@@ -481,30 +488,37 @@ export class Act {
}, },
{ {
label: Option.NoCacheServer, label: Option.NoCacheServer,
description: 'false',
detail: 'Disable cache server.' detail: 'Disable cache server.'
}, },
{ {
label: Option.NoRecurse, label: Option.NoRecurse,
description: 'false',
detail: 'Flag to disable running workflows from subdirectories of specified path in --workflows/-W flag.' detail: 'Flag to disable running workflows from subdirectories of specified path in --workflows/-W flag.'
}, },
{ {
label: Option.NoSkipCheckout, label: Option.NoSkipCheckout,
description: 'false',
detail: 'Do not skip actions/checkout.' detail: 'Do not skip actions/checkout.'
}, },
{ {
label: Option.Privileged, label: Option.Privileged,
description: 'false',
detail: 'Use privileged mode.' detail: 'Use privileged mode.'
}, },
{ {
label: Option.Pull, label: Option.Pull,
description: 'true',
detail: 'Pull docker image(s) even if already present.' detail: 'Pull docker image(s) even if already present.'
}, },
{ {
label: Option.Quiet, label: Option.Quiet,
description: 'false',
detail: 'Disable logging of output from steps.' detail: 'Disable logging of output from steps.'
}, },
{ {
label: Option.Rebuild, label: Option.Rebuild,
description: 'true',
detail: 'Rebuild local action docker image(s) even if already present.' detail: 'Rebuild local action docker image(s) even if already present.'
}, },
{ {
@@ -524,18 +538,22 @@ export class Act {
}, },
{ {
label: Option.Reuse, label: Option.Reuse,
description: 'false',
detail: 'Don\'t remove container(s) on successfully completed workflow(s) to maintain state between runs.' detail: 'Don\'t remove container(s) on successfully completed workflow(s) to maintain state between runs.'
}, },
{ {
label: Option.Rm, label: Option.Rm,
description: 'false',
detail: 'Automatically remove container(s)/volume(s) after a workflow(s) failure.' detail: 'Automatically remove container(s)/volume(s) after a workflow(s) failure.'
}, },
{ {
label: Option.UseGitignore, label: Option.UseGitignore,
description: 'true',
detail: 'Controls whether paths specified in a .gitignore file should be copied into the container.' detail: 'Controls whether paths specified in a .gitignore file should be copied into the container.'
}, },
{ {
label: Option.UseNewActionCache, label: Option.UseNewActionCache,
description: 'false',
detail: 'Enable using the new Action Cache for storing Actions locally.' detail: 'Enable using the new Action Cache for storing Actions locally.'
}, },
{ {
@@ -545,6 +563,7 @@ export class Act {
}, },
{ {
label: Option.Verbose, label: Option.Verbose,
description: 'false',
detail: 'Enable verbose output.' detail: 'Enable verbose output.'
} }
]; ];
@@ -616,7 +635,7 @@ export class Act {
(settings.inputFiles.length > 0 ? `${Option.InputFile} "${settings.inputFiles[0].path}"` : `${Option.InputFile} ""`), (settings.inputFiles.length > 0 ? `${Option.InputFile} "${settings.inputFiles[0].path}"` : `${Option.InputFile} ""`),
...settings.runners.map(runner => `${Option.Platform} ${runner.key}=${runner.value}`), ...settings.runners.map(runner => `${Option.Platform} ${runner.key}=${runner.value}`),
(settings.payloadFiles.length > 0 ? `${Option.EventPath} "${settings.payloadFiles[0].path}"` : `${Option.EventPath} ""`), (settings.payloadFiles.length > 0 ? `${Option.EventPath} "${settings.payloadFiles[0].path}"` : `${Option.EventPath} ""`),
...settings.options.map(option => option.path ? `--${option.name} ${option.path}` : `--${option.name}`) ...settings.options.map(option => option.path ? `--${option.name}${option.default && ['true', 'false'].includes(option.default) ? "=" : " "}${option.path}` : `--${option.name}`)
]; ];
const command = `${actCommand} ${Option.Json} ${Option.Verbose} ${commandArgs.options.join(' ')} ${userOptions.join(' ')}`; const command = `${actCommand} ${Option.Json} ${Option.Verbose} ${commandArgs.options.join(' ')} ${userOptions.join(' ')}`;

View File

@@ -139,7 +139,7 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
]; ];
options = allOptions.map(opt => ({ options = allOptions.map(opt => ({
label: "--" + opt.name, label: "--" + opt.name,
description: opt.type !== 'bool' ? (opt.type === 'stringArray' ? '' : opt.default) : undefined, description: opt.type === 'stringArray' ? '' : opt.default,
detail: opt.description ? (opt.description.charAt(0).toUpperCase() + opt.description.slice(1)) : undefined detail: opt.description ? (opt.description.charAt(0).toUpperCase() + opt.description.slice(1)) : undefined
})).filter(opt => !excludeOptions.includes(opt.label)); })).filter(opt => !excludeOptions.includes(opt.label));
} catch (error: any) { } catch (error: any) {
@@ -162,11 +162,18 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
let value: string | undefined; let value: string | undefined;
if (requiresInputFromUser) { if (requiresInputFromUser) {
value = await window.showInputBox({ if (['true', 'false'].includes(selectedOption.description)) {
prompt: `Enter a value for the option`, value = (await window.showQuickPick([{ label: 'true' }, { label: 'false' }], {
placeHolder: `Option value`, title: `Select a value for the option ${selectedOption.label}`,
value: selectedOption.description placeHolder: selectedOption.label,
}); }))?.label;
} else {
value = await window.showInputBox({
prompt: `Enter a value for the option ${selectedOption.label}`,
placeHolder: selectedOption.label,
value: selectedOption.description
});
}
if (value === undefined) { if (value === undefined) {
return; return;
@@ -204,11 +211,19 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
} }
}), }),
commands.registerCommand('githubLocalActions.editOption', async (optionTreeItem: OptionTreeItem) => { commands.registerCommand('githubLocalActions.editOption', async (optionTreeItem: OptionTreeItem) => {
const value = await window.showInputBox({ let value: string | undefined;
prompt: `Enter a value for the option (${optionTreeItem.option.name})`, if (optionTreeItem.option.default && ['true', 'false'].includes(optionTreeItem.option.default)) {
placeHolder: `Option value`, value = (await window.showQuickPick([{ label: 'true' }, { label: 'false' }], {
value: optionTreeItem.option.path title: `Select a value for the option ${optionTreeItem.option.name}`,
}); placeHolder: optionTreeItem.option.name,
}))?.label;
} else {
value = await window.showInputBox({
prompt: `Enter a value for the option ${optionTreeItem.option.name}`,
placeHolder: optionTreeItem.option.name,
value: optionTreeItem.option.path
});
}
if (value !== undefined) { if (value !== undefined) {
const newOption = optionTreeItem.option; const newOption = optionTreeItem.option;