Skip to content

Commit

Permalink
Added --createDirectory command line argument to suppress the prompt (
Browse files Browse the repository at this point in the history
#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 <[email protected]>
  • Loading branch information
HenrikHoyer and Henrik Høyer authored Nov 22, 2024
1 parent ee855d7 commit 80f9d9d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public GenerateCommand(ILogger<GenerateCommand> logger, ILoggerFactory loggerFac
[Option("--githubactions", Description = "Convert to GitHub Actions (also forces inline to true) [default: false]")]
public bool gitHubActions { get; }

[Option("--create-directory", Description = "Create the destination directory if it does not exist [default: false]")]
public bool createDirectory { get; }

public async Task<int> OnExecuteAsync()
{
if (gitHubActions) inlineTaskGroups = true;//github actions don't support templates
Expand Down Expand Up @@ -102,8 +105,8 @@ public async Task<int> OnExecuteAsync()
if (!Path.GetFileName(rootPath).Equals(_project.Name, StringComparison.OrdinalIgnoreCase))
rootPath = Path.Combine(rootPath, _project.Name);
if (!Directory.Exists(rootPath))
if (Prompt.GetYesNo($"Directory '{rootPath}' does not exist, create?", true))
Directory.CreateDirectory(rootPath);//create the output folder if doesn't exist
if (createDirectory || Prompt.GetYesNo($"Directory '{rootPath}' does not exist, create?", true))
Directory.CreateDirectory(rootPath);//create the output folder if it doesn't exist
else
return 1;

Expand Down

0 comments on commit 80f9d9d

Please sign in to comment.