-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
133 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
namespace MinVer | ||
{ | ||
using System; | ||
|
||
internal class Logger : ILogger | ||
{ | ||
private readonly Verbosity level; | ||
|
||
public Logger(Verbosity level) => this.level = level; | ||
|
||
public bool IsDebugEnabled => this.level >= Verbosity.Debug; | ||
|
||
public void Debug(Func<string> createMessage) | ||
{ | ||
if (this.level >= Verbosity.Debug) | ||
{ | ||
Message(createMessage()); | ||
} | ||
} | ||
|
||
public void Debug(string message) | ||
{ | ||
if (this.level >= Verbosity.Debug) | ||
{ | ||
Message(message); | ||
} | ||
} | ||
|
||
public void Info(string message) | ||
{ | ||
if (this.level >= Verbosity.Info) | ||
{ | ||
Message(message); | ||
} | ||
} | ||
|
||
public void WarnInvalidRepoPath(string path, Version version) => | ||
this.Warn($"'{path}' is not a valid repository or working directory. Using default version: {version}"); | ||
|
||
public static void ErrorInvalidRepoPath(string path) => | ||
Error($"Invalid repository path '{path}'. Directory does not exist."); | ||
|
||
public static void ErrorInvalidMajorMinorRange(string majorMinor) => | ||
Error($"Invalid MAJOR.MINOR range '{majorMinor}'."); | ||
|
||
public static void ErrorInvalidVerbosityLevel(string verbosity) => | ||
Error($"Invalid verbosity level '{verbosity}'. Valid levels are error, warn, info, debug, and trace."); | ||
|
||
private void Warn(string message) | ||
{ | ||
if (this.level >= Verbosity.Warn) | ||
{ | ||
Message($"warning : {message}"); | ||
} | ||
} | ||
|
||
private static void Error(string message) => Message($"error : {message}"); | ||
|
||
private static void Message(string message) => Console.Error.WriteLine($"MinVer: {message}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace MinVer | ||
{ | ||
internal enum Verbosity | ||
{ | ||
Error = -2, | ||
Warn = -1, | ||
Info = 0, | ||
Debug = 1, | ||
Trace = 2, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<Description>Minimalistic versioning for .NET SDK-style projects.</Description> | ||
<OutputType>Exe</OutputType> | ||
<PackAsTool>true</PackAsTool> | ||
<PackageIconUrl>https://raw.githubusercontent.com/adamralph/min-ver/master/assets/min-ver.png</PackageIconUrl> | ||
<PackageLicenseUrl>https://github.com/adamralph/min-ver/blob/master/LICENSE</PackageLicenseUrl> | ||
<PackageProjectUrl>https://github.com/adamralph/min-ver</PackageProjectUrl> | ||
<PackageReleaseNotes>https://github.com/adamralph/min-ver/milestones?state=closed</PackageReleaseNotes> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\MinVer.Tasks\Program.cs" Link="Program.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="LibGit2Sharp" Version="0.25.3" /> | ||
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.2.5" /> | ||
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.6.2" PrivateAssets="All" /> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63127-02" PrivateAssets="All" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\MinVer\MinVer.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters