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

View File

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