diff --git a/src/Cli/Cli.csproj b/src/Cli/Cli.csproj index 2c9a5ac..830fdaa 100644 --- a/src/Cli/Cli.csproj +++ b/src/Cli/Cli.csproj @@ -6,10 +6,11 @@ Cli true update-tag + update-tag Novaloop.UpdateTag Updates the tag of a repo to the next chosen version according the semver symantic. semver;update-tag;tag;git - 0.4.0 + 0.5.0 Matthias Langhard Novaloop AG https://gitlab.com/novaloop-oss/novaloop.update-tag @@ -18,6 +19,7 @@ + diff --git a/src/Cli/Models/CliParams.cs b/src/Cli/Models/CliParams.cs new file mode 100644 index 0000000..9a77b8c --- /dev/null +++ b/src/Cli/Models/CliParams.cs @@ -0,0 +1,10 @@ +using CommandLine; + +namespace Cli.Models +{ + public class CliParams + { + [Option('r', "repository-path", Required = false, HelpText = "Run update-tag on a git repository other than the current directory.")] + public string RepositoryPath { get; set; } + } +} \ No newline at end of file diff --git a/src/Cli/Program.cs b/src/Cli/Program.cs index 869d98b..77722c9 100644 --- a/src/Cli/Program.cs +++ b/src/Cli/Program.cs @@ -1,7 +1,8 @@ using System; -using System.Linq; using System.Threading.Tasks; using Application; +using Cli.Models; +using CommandLine; using Infrastructure; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -21,9 +22,14 @@ namespace Cli .ServiceProvider .GetRequiredService(); - await appRunner.Run(args.FirstOrDefault() ?? Environment.CurrentDirectory); + await Parser.Default + .ParseArguments(args) + .WithParsedAsync( + async options => { await appRunner.Run(options.RepositoryPath ?? Environment.CurrentDirectory); } + ); } + private static IHostBuilder CreateHostBuilder() { return Host.CreateDefaultBuilder()