Skip to content

Commit

Permalink
Add --list option to list zones
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerszabo committed Feb 21, 2018
1 parent e2d93ff commit dece625
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions RGBFusionTool/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public void Main(string[] args)
string opt_ColorCycle = null;
bool flag_DoCycle = false;
bool flag_Help = false;
bool flag_List = false;
string opt_Brightness = null;

OptionSet options = new OptionSet
Expand All @@ -51,6 +52,8 @@ public void Main(string[] args)
{"cycle|colorcycle:", "cycle colors, changing color every {SECONDS}", v => { flag_DoCycle = true; opt_ColorCycle = v; } },
{"b|brightness=", "brightness (0-100)", v => opt_Brightness = v },

{"l|list", "list zones", v => flag_List = true },

{"?|h|help", "show help and exit", v => flag_Help = true },

{"<>", v => { throw new OptionException(string.Format("Unexpected option \"{0}\"", v),"default"); } }
Expand All @@ -69,6 +72,15 @@ public void Main(string[] args)
return;
}

if (flag_List)
{
for (int i = 0; i < motherboardLEDs.Layout.Length; i++)
{
stdout.WriteLine("Zone {0}: {1}", i, motherboardLEDs.Layout[i]);
}
return;
}

if (!string.IsNullOrWhiteSpace(opt_Brightness))
{
brightness = byte.Parse(opt_Brightness);
Expand Down
13 changes: 13 additions & 0 deletions RGBFusionToolTests/RGBFusionToolExeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,5 +280,18 @@ public void ColorCycle_500ms(string[] args)
GLedApiDotNetTests.Tests.LedSettingTests.SettingByteArrays.ColorCycleA_500ms,
GLedApiv1_0_0Mock.DEFAULT_MAXDIVISIONS);
}

[DataRow(new string[] { "--list" }, DisplayName = "--list")]
[DataRow(new string[] { "-l" }, DisplayName = "-l")]
[DataTestMethod]
public void List(string[] args)
{
rgbFusionTool.Main(args);

StringAssert.DoesNotMatch(stderr.ToString(), ANY, "Expect stderr is empty");
StringAssert.Matches(stdout.ToString(), new Regex("zone \\d+", RegexOptions.IgnoreCase), "Expect stdout lists zones");

Assert.IsTrue(mock.IsInitialized, "Expect initialized");
}
}
}

0 comments on commit dece625

Please sign in to comment.