Skip to content

Commit 80f9d9d

Browse files
HenrikHoyerHenrik Høyer
andauthored
Added --createDirectory command line argument to suppress the prompt (#228)
* Added `--createDirectory` command line argument to supress the prompt * kebab-cased the option (--create-directory) and fixed the indentation --------- Co-authored-by: Henrik Høyer <Henrik@crunch-it.dk>
1 parent ee855d7 commit 80f9d9d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public GenerateCommand(ILogger<GenerateCommand> logger, ILoggerFactory loggerFac
5050
[Option("--githubactions", Description = "Convert to GitHub Actions (also forces inline to true) [default: false]")]
5151
public bool gitHubActions { get; }
5252

53+
[Option("--create-directory", Description = "Create the destination directory if it does not exist [default: false]")]
54+
public bool createDirectory { get; }
55+
5356
public async Task<int> OnExecuteAsync()
5457
{
5558
if (gitHubActions) inlineTaskGroups = true;//github actions don't support templates
@@ -102,8 +105,8 @@ public async Task<int> OnExecuteAsync()
102105
if (!Path.GetFileName(rootPath).Equals(_project.Name, StringComparison.OrdinalIgnoreCase))
103106
rootPath = Path.Combine(rootPath, _project.Name);
104107
if (!Directory.Exists(rootPath))
105-
if (Prompt.GetYesNo($"Directory '{rootPath}' does not exist, create?", true))
106-
Directory.CreateDirectory(rootPath);//create the output folder if doesn't exist
108+
if (createDirectory || Prompt.GetYesNo($"Directory '{rootPath}' does not exist, create?", true))
109+
Directory.CreateDirectory(rootPath);//create the output folder if it doesn't exist
107110
else
108111
return 1;
109112

0 commit comments

Comments
 (0)