Skip to content

Commit 7506535

Browse files
committed
Updates package versions and command-line parsing
Upgrades System.CommandLine and XAMLTest package versions; refactors CommandLineOptions to use the updated System.CommandLine API for option definition and value retrieval.
1 parent 35cf8ae commit 7506535

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

Directory.packages.props

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
<PackageVersion Include="Microsoft.Toolkit.MVVM" Version="7.1.2" />
2626
<PackageVersion Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
2727
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
28+
<PackageVersion Include="Polyfill" Version="8.8.1" />
2829
<PackageVersion Include="Shouldly" Version="4.3.0" />
2930
<PackageVersion Include="ShowMeTheXAML" Version="2.0.0" />
3031
<PackageVersion Include="ShowMeTheXAML.AvalonEdit" Version="2.0.0" />
3132
<PackageVersion Include="ShowMeTheXAML.MSBuild" Version="2.0.0" />
32-
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
33+
<PackageVersion Include="System.CommandLine" Version="2.0.2" />
34+
<PackageVersion Include="System.Memory" Version="4.6.3" />
3335
<PackageVersion Include="System.Private.Uri" Version="4.3.2" />
36+
<PackageVersion Include="System.ValueTuple" Version="4.6.1" />
3437
<PackageVersion Include="TUnit" Version="0.25.21" />
3538
<PackageVersion Include="VirtualizingWrapPanel" Version="1.5.8" />
36-
<PackageVersion Include="XAMLTest" Version="1.3.0-ci616" />
37-
<PackageVersion Include="System.Memory" Version="4.6.3" />
38-
<PackageVersion Include="System.ValueTuple" Version="4.6.1" />
39-
<PackageVersion Include="Polyfill" Version="8.8.1" />
39+
<PackageVersion Include="XAMLTest" Version="1.3.1-ci662" />
4040
</ItemGroup>
4141
</Project>
Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
using System.CommandLine;
2-
using System.CommandLine.Parsing;
32
using MaterialDesignThemes.Wpf;
43

54
namespace MaterialDesign.Shared;
65

76
internal static class CommandLineOptions
87
{
98
private static readonly Option<string> PageOption =
10-
new(aliases: new[] {"--page", "-p"},
11-
getDefaultValue: () => "Home",
12-
description: "Sets the startup page of the Demo app.");
9+
new("--page", "-p")
10+
{
11+
DefaultValueFactory = _ => "Home",
12+
Description = "Sets the startup page of the Demo app."
13+
};
1314

1415
private static readonly Option<FlowDirection> FlowDirectionOption =
15-
new(aliases: new[] { "--flowDirection", "-f" },
16-
getDefaultValue: () => FlowDirection.LeftToRight,
17-
description: "Sets the startup flow direction of the Demo app.");
16+
new("--flowDirection", "-f")
17+
{
18+
DefaultValueFactory = _ => FlowDirection.LeftToRight,
19+
Description = "Sets the startup flow direction of the Demo app."
20+
};
1821

1922
private static readonly Option<BaseTheme> ThemeOption =
20-
new(aliases: new[] { "--theme", "-t" },
21-
getDefaultValue: () => BaseTheme.Inherit,
22-
description: "Sets the startup theme of the Demo app.");
23+
new("--theme", "-t")
24+
{
25+
DefaultValueFactory = _ => BaseTheme.Inherit,
26+
Description = "Sets the startup theme of the Demo app."
27+
};
2328

2429
private static readonly RootCommand RootCommand =
2530
new(description: "MaterialDesignInXamlToolkit Demo app command line options.")
@@ -34,9 +39,9 @@ public static (string? StartPage, FlowDirection FlowDirection, BaseTheme BaseThe
3439
ParseResult parseResult = RootCommand.Parse(args);
3540

3641
return new(
37-
parseResult.GetValueForOption(PageOption),
38-
parseResult.GetValueForOption(FlowDirectionOption),
39-
parseResult.GetValueForOption(ThemeOption)
42+
parseResult.GetValue(PageOption),
43+
parseResult.GetValue(FlowDirectionOption),
44+
parseResult.GetValue(ThemeOption)
4045
);
4146
}
4247
}

0 commit comments

Comments
 (0)