Added "--version" switch for version printing.
parent
35aa50fba6
commit
b87920e5aa
|
@ -1,7 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using CommandLine;
|
using CommandLine;
|
||||||
using CommandLine.Text;
|
using CommandLine.Text;
|
||||||
|
@ -23,6 +21,9 @@ namespace CitizenMP.Server.Installer
|
||||||
[ValueOption(0)]
|
[ValueOption(0)]
|
||||||
public string OutputPath { get; set; }
|
public string OutputPath { get; set; }
|
||||||
|
|
||||||
|
[Option("version", DefaultValue=false, HelpText="Shows this tool's version.")]
|
||||||
|
public bool ShowVersion { get; set; }
|
||||||
|
|
||||||
[HelpOption]
|
[HelpOption]
|
||||||
public string GetUsage()
|
public string GetUsage()
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,6 +67,42 @@ namespace CitizenMP.Server.Installer
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.ShowVersion)
|
||||||
|
{
|
||||||
|
var version =
|
||||||
|
Regex.Match(
|
||||||
|
Assembly.GetExecutingAssembly()
|
||||||
|
.GetCustomAttributes(typeof (AssemblyInformationalVersionAttribute), false)
|
||||||
|
.OfType<AssemblyInformationalVersionAttribute>().First().InformationalVersion,
|
||||||
|
@"^(?<major>[0-9]+)\.(?<minor>[0-9]+)\.(?<revision>[0-9]+)(\-(?<prerelease>[A-z0-9\.]+))?(\+(?<meta>.+?))?$");
|
||||||
|
|
||||||
|
var meta = new Queue<string>(version.Groups["meta"].Value.Split('.'));
|
||||||
|
while (meta.Any() && meta.First() != "Branch")
|
||||||
|
{
|
||||||
|
meta.Dequeue();
|
||||||
|
}
|
||||||
|
|
||||||
|
var metaDict = new Dictionary<string, string>();
|
||||||
|
while (meta.Any())
|
||||||
|
{
|
||||||
|
var name = meta.Dequeue();
|
||||||
|
var value = meta.Dequeue();
|
||||||
|
if (meta.Any() && char.IsDigit(meta.First().First()))
|
||||||
|
{
|
||||||
|
value += "." + meta.Dequeue();
|
||||||
|
}
|
||||||
|
metaDict.Add(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("{0}.{1}.{2}{3}{4}",
|
||||||
|
version.Groups["major"].Value,
|
||||||
|
version.Groups["minor"].Value,
|
||||||
|
version.Groups["revision"].Value,
|
||||||
|
version.Groups["prerelease"].Success ? "-" + version.Groups["prerelease"].Value : "",
|
||||||
|
metaDict.Any() ? " (" + metaDict["Sha"].Substring(0, 7) + ")" : "");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(options.OutputPath))
|
if (string.IsNullOrEmpty(options.OutputPath))
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("ERROR: No output directory given.");
|
Console.Error.WriteLine("ERROR: No output directory given.");
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
#if !NO_COMMANDLINE
|
#if !NO_COMMANDLINE
|
||||||
using CommandLine;
|
using CommandLine;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue