diff --git a/GLedApiDotNet/Properties/AssemblyInfo.cs b/GLedApiDotNet/Properties/AssemblyInfo.cs index b1986c8..0aa0582 100644 --- a/GLedApiDotNet/Properties/AssemblyInfo.cs +++ b/GLedApiDotNet/Properties/AssemblyInfo.cs @@ -14,7 +14,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("GLedApiDotNet")] -[assembly: AssemblyDescription(".NET wrapper for Gigabyte's RGB Fusion GLedApi.dll")] +[assembly: AssemblyDescription(".NET wrapper for Gigabyte's RGB Fusion GLedApi.dll - Source: https://github.com/tylerszabo/RGB-Fusion-Tool")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("GLedApiDotNet")] diff --git a/RGBFusionTool/Application.cs b/RGBFusionTool/Application.cs index 763dd7c..0c99643 100644 --- a/RGBFusionTool/Application.cs +++ b/RGBFusionTool/Application.cs @@ -26,6 +26,7 @@ private class ApplicationContext { public bool flag_Help; public bool flag_List; + public bool flag_Version; public int verbosity; public ApplicationContext() @@ -37,6 +38,7 @@ public void SetDefaults() { flag_Help = false; flag_List = false; + flag_Version = false; verbosity = 0; } } @@ -72,6 +74,7 @@ public Application(IRGBFusionMotherboard motherboardLEDs, TextWriter stdout, Tex { "v|verbose", v => context.verbosity++ }, { "l|list", "list zones", v => context.flag_List = true }, { "?|h|help", "show help and exit", v => context.flag_Help = true }, + { "version", "show version information and exit", v => context.flag_Version = true }, { "" } }; @@ -129,6 +132,30 @@ private void ShowHelp(TextWriter o) } } + private void ShowVersion(TextWriter o) + { + string gplNotice = +@"This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see ."; + + o.WriteLine("RGB Fusion Tool {0}", System.Reflection.Assembly.GetAssembly(this.GetType()).GetName().Version); + o.WriteLine("Copyright (C) 2018 Tyler Szabo"); + o.WriteLine(); + o.WriteLine(gplNotice); + o.WriteLine(); + o.WriteLine("Source: https://github.com/tylerszabo/RGB-Fusion-Tool"); + } + public void Main(string[] args) { context.SetDefaults(); @@ -143,6 +170,12 @@ public void Main(string[] args) return; } + if (context.flag_Version) + { + ShowVersion(stdout); + return; + } + zoneOptions.Parse(afterGeneric); if (context.flag_List || context.verbosity > 0) diff --git a/RGBFusionTool/Properties/AssemblyInfo.cs b/RGBFusionTool/Properties/AssemblyInfo.cs index 00f7f1b..6bee589 100644 --- a/RGBFusionTool/Properties/AssemblyInfo.cs +++ b/RGBFusionTool/Properties/AssemblyInfo.cs @@ -13,11 +13,11 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("RGBFusionTool")] +[assembly: AssemblyTitle("RGB Fusion Tool")] [assembly: AssemblyDescription("Tool for Gigabyte's RGB Fusion motherboard LEDs")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("RGBFusionTool")] +[assembly: AssemblyProduct("RGB Fusion Tool")] [assembly: AssemblyCopyright("Copyright © 2018 Tyler Szabo")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/RGBFusionToolTests/RGBFusionToolExeTests.cs b/RGBFusionToolTests/RGBFusionToolExeTests.cs index 6a10ccc..f831d38 100644 --- a/RGBFusionToolTests/RGBFusionToolExeTests.cs +++ b/RGBFusionToolTests/RGBFusionToolExeTests.cs @@ -77,7 +77,8 @@ public void Help(string[] args) "verbose", "list", - "help" + "help", + "version" }; foreach (string option in supportedOptions) { @@ -86,6 +87,32 @@ public void Help(string[] args) } } + [DataRow(new string[] { "--version" }, DisplayName = "--version")] + [DataTestMethod] + public void Version(string[] args) + { + rgbFusionTool.Main(args); + + Assert.IsFalse(mock.IsInitialized, "Expect uninitialized"); + StringAssert.DoesNotMatch(stderr.ToString(), ANY, "Expect stderr is empty"); + + string[] requiredPatterns = { + "\\bRGB Fusion Tool\\b\\s+\\b\\d+(\\.\\d+){1,3}\\b", // name and version + "\\b[cC]opyright\\b\\s+(\\([cC]\\)\\s+)\\b2018\\b\\s+\\bTyler Szabo\\b", // copyright year and name + + "\\bGNU General Public License\\b", + "\\bFree Software Foundation\\b", + "\\bversion 3\\b", + "\\bWITHOUT ANY WARRANTY\\b", + "https://www.gnu.org/licenses/" + }; + foreach (string pattern in requiredPatterns) + { + Regex regex = new Regex(pattern); + StringAssert.Matches(stdout.ToString(), regex, "Expect stdout shows version information"); + } + } + [TestMethod] public void NoArgs() {