diff --git a/src/CodeOfChaos.CliArgsParser.Generators/CodeOfChaos.CliArgsParser.Generators.csproj b/src/CodeOfChaos.CliArgsParser.Generators/CodeOfChaos.CliArgsParser.Generators.csproj index 0bbb4c1..a4d8b8b 100644 --- a/src/CodeOfChaos.CliArgsParser.Generators/CodeOfChaos.CliArgsParser.Generators.csproj +++ b/src/CodeOfChaos.CliArgsParser.Generators/CodeOfChaos.CliArgsParser.Generators.csproj @@ -11,7 +11,7 @@ CodeOfChaos.CliArgsParser.Generators - 4.3.4 + 4.4.0 Anna Sas CliArgsParser is a library built around Dependency Injection to allow you to create CLI tools with ease https://github.com/code-of-chaos/cs-code_of_chaos-cli_args_parser/ diff --git a/src/CodeOfChaos.CliArgsParser.Library/CodeOfChaos.CliArgsParser.Library.csproj b/src/CodeOfChaos.CliArgsParser.Library/CodeOfChaos.CliArgsParser.Library.csproj index 0776f00..afe5792 100644 --- a/src/CodeOfChaos.CliArgsParser.Library/CodeOfChaos.CliArgsParser.Library.csproj +++ b/src/CodeOfChaos.CliArgsParser.Library/CodeOfChaos.CliArgsParser.Library.csproj @@ -8,7 +8,7 @@ CodeOfChaos.CliArgsParser.Library - 4.3.4 + 4.4.0 Anna Sas CliArgsParser is a library built around Dependency Injection to allow you to create CLI tools with ease https://github.com/code-of-chaos/cs-code_of_chaos-cli_args_parser/ @@ -34,6 +34,6 @@ - + \ No newline at end of file diff --git a/src/CodeOfChaos.CliArgsParser.Library/Shared/SemanticVersionDto.cs b/src/CodeOfChaos.CliArgsParser.Library/Shared/SemanticVersionDto.cs index 9cb80a7..5d099ec 100644 --- a/src/CodeOfChaos.CliArgsParser.Library/Shared/SemanticVersionDto.cs +++ b/src/CodeOfChaos.CliArgsParser.Library/Shared/SemanticVersionDto.cs @@ -61,32 +61,29 @@ public void BumpVersion(VersionSection section) { return; } + case VersionSection.Preview when Preview is null: { + SemanticVersionDto newVersion = FromInput("Please enter a semantic version for the new preview version:"); + + Major = newVersion.Major; + Minor = newVersion.Minor; + Patch = newVersion.Patch; + Preview = newVersion.Preview ?? 0 ; + return; + } + case VersionSection.Preview: { - Preview ??= 0; Preview += 1; return; } case VersionSection.Manual: { - // Ask the user for input - int tries = 0; - while (tries <= 5) { - Console.WriteLine("Please enter a semantic version:"); - string? input = Console.ReadLine(); - if (input is null || !TryParse(input, out SemanticVersionDto? newVersion)) { - Console.WriteLine("Invalid input"); - tries++; - continue; - } - - Major = newVersion.Major; - Minor = newVersion.Minor; - Patch = newVersion.Patch; - Preview = newVersion.Preview; - return; - } - - throw new Exception("Could not parse version after 5 tries."); + SemanticVersionDto newVersion = FromInput(); + + Major = newVersion.Major; + Minor = newVersion.Minor; + Patch = newVersion.Patch; + Preview = newVersion.Preview; + return; } // We don't care @@ -99,4 +96,18 @@ public void BumpVersion(VersionSection section) { public override string ToString() => Preview is not null ? $"{Major}.{Minor}.{Patch}-preview.{Preview}" : $"{Major}.{Minor}.{Patch}"; + + private static SemanticVersionDto FromInput(string inputText = "Please enter a semantic version:") { + int tries = 0; + while (tries <= 5) { + Console.WriteLine(inputText); + string? input = Console.ReadLine(); + if (input is not null && TryParse(input, out SemanticVersionDto? newVersion)) return newVersion; + + Console.WriteLine("Invalid input"); + tries++; + } + + throw new Exception("Could not parse version after 5 tries."); + } } diff --git a/src/CodeOfChaos.CliArgsParser/CodeOfChaos.CliArgsParser.csproj b/src/CodeOfChaos.CliArgsParser/CodeOfChaos.CliArgsParser.csproj index 3f130ed..53d4754 100644 --- a/src/CodeOfChaos.CliArgsParser/CodeOfChaos.CliArgsParser.csproj +++ b/src/CodeOfChaos.CliArgsParser/CodeOfChaos.CliArgsParser.csproj @@ -7,7 +7,7 @@ CodeOfChaos.CliArgsParser - 4.3.4 + 4.4.0 Anna Sas CliArgsParser is a library built around Dependency Injection to allow you to create CLI tools with ease https://github.com/code-of-chaos/cs-code_of_chaos-cli_args_parser/ diff --git a/tests/Tests.CodeOfChaos.CliArgsParser/Tests.CodeOfChaos.CliArgsParser.csproj b/tests/Tests.CodeOfChaos.CliArgsParser/Tests.CodeOfChaos.CliArgsParser.csproj index 462851d..0859f8c 100644 --- a/tests/Tests.CodeOfChaos.CliArgsParser/Tests.CodeOfChaos.CliArgsParser.csproj +++ b/tests/Tests.CodeOfChaos.CliArgsParser/Tests.CodeOfChaos.CliArgsParser.csproj @@ -12,7 +12,7 @@ - +