Skip to content

Commit

Permalink
VersionBump : v4.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaSasDev committed Jan 9, 2025
1 parent bfe0d25 commit 13995c1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<!-- Main package name -->
<PackageId>CodeOfChaos.CliArgsParser.Generators</PackageId>
<Version>4.3.4</Version>
<Version>4.4.0</Version>
<Authors>Anna Sas</Authors>
<Description>CliArgsParser is a library built around Dependency Injection to allow you to create CLI tools with ease</Description>
<PackageProjectUrl>https://github.com/code-of-chaos/cs-code_of_chaos-cli_args_parser/</PackageProjectUrl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<!-- Main package name -->
<PackageId>CodeOfChaos.CliArgsParser.Library</PackageId>
<Version>4.3.4</Version>
<Version>4.4.0</Version>
<Authors>Anna Sas</Authors>
<Description>CliArgsParser is a library built around Dependency Injection to allow you to create CLI tools with ease</Description>
<PackageProjectUrl>https://github.com/code-of-chaos/cs-code_of_chaos-cli_args_parser/</PackageProjectUrl>
Expand All @@ -34,6 +34,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AterraEngine.Unions" Version="2.7.1" />
<PackageReference Include="AterraEngine.Unions" Version="3.6.0" />
</ItemGroup>
</Project>
51 changes: 31 additions & 20 deletions src/CodeOfChaos.CliArgsParser.Library/Shared/SemanticVersionDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<!-- Main package name -->
<PackageId>CodeOfChaos.CliArgsParser</PackageId>
<Version>4.3.4</Version>
<Version>4.4.0</Version>
<Authors>Anna Sas</Authors>
<Description>CliArgsParser is a library built around Dependency Injection to allow you to create CLI tools with ease</Description>
<PackageProjectUrl>https://github.com/code-of-chaos/cs-code_of_chaos-cli_args_parser/</PackageProjectUrl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0"/>
<PackageReference Include="Moq" Version="4.20.72"/>
<PackageReference Include="TUnit" Version="0.6.15"/>
<PackageReference Include="TUnit" Version="0.6.55" />
<PackageReference Include="Bogus" Version="35.6.1"/>
</ItemGroup>

Expand Down

0 comments on commit 13995c1

Please sign in to comment.