Skip to content

Commit

Permalink
Fixes #26 , Added version option.
Browse files Browse the repository at this point in the history
Its on by default and can be turned off with settings
  • Loading branch information
Bilal Fazlani committed Jan 9, 2018
1 parent 5f22ba0 commit 1a619a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
12 changes: 12 additions & 0 deletions CommandDotNet/AppCreator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Reflection;
using CommandDotNet.Attributes;
using CommandDotNet.MicrosoftCommandLineUtils;
Expand Down Expand Up @@ -30,6 +31,8 @@ public CommandLineApplication CreateApplication(
{
string rootName = $"dotnet {Assembly.GetEntryAssembly().GetName().Name}.dll";
app = new CommandLineApplication(throwOnUnexpectedArg: _appSettings.ThrowOnUnexpectedArgument) { Name = rootName };

AddVersion(app);
}
else
{
Expand Down Expand Up @@ -59,5 +62,14 @@ public CommandLineApplication CreateApplication(

return app;
}

private void AddVersion(CommandLineApplication app)
{
if (_appSettings.EnableVersionOption)
{
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location);
app.VersionOption("-v | --version", shortFormVersion: fvi.ProductVersion);
}
}
}
}
8 changes: 0 additions & 8 deletions CommandDotNet/Enums/MultiValueType.cs

This file was deleted.

2 changes: 2 additions & 0 deletions CommandDotNet/Models/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public AppSettings()
public ArgumentMode MethodArgumentMode { get; set; } = ArgumentMode.Parameter;

public Case Case { get; set; } = Case.DontChange;

public bool EnableVersionOption { get; set; } = true;
}

public enum ArgumentMode
Expand Down

0 comments on commit 1a619a6

Please sign in to comment.