forked from UbiquityDotNET/Ubiquity.NET.Utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestOptions.cs
More file actions
54 lines (43 loc) · 2.19 KB
/
TestOptions.cs
File metadata and controls
54 lines (43 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
#pragma warning disable IDE0130 // Namespace does not match folder structure
using System.IO;
using System.Linq;
using Ubiquity.NET.CommandLine.GeneratorAttributes;
using Ubiquity.NET.Extensions;
namespace TestNamespace
{
[RootCommand( Description = "Root command for tests" )]
internal partial class TestOptions
{
[Option( "-o", Description = "Test SomePath", Required = true )]
[FolderValidation( FolderValidation.CreateIfNotExist )]
public required DirectoryInfo SomePath { get; init; }
[Option( "-v", Description = "Verbosity Level" )]
public MessageLevel Verbosity { get; init; } = MessageLevel.Information;
[Option( "-b", Description = "Test Some existing Path", Required = true )]
[FolderValidation( FolderValidation.ExistingOnly )]
public required DirectoryInfo SomeExistingPath { get; init; }
[Option( "--thing1", Aliases = [ "-t" ], Description = "Test Thing1", HelpName = "Help name for thing1" )]
public bool? Thing1 { get; init; }
// This should be ignored by generator
public string? NotAnOption { get; set; }
[Option( "-i", ArityMin = 0, Description = "include path" )]
public required DirectoryInfo[] IncludePath { get; init; }
[Option( "-a", Hidden = true, Required = false, Description = "Test SomeOtherPath" )]
[FileValidation( FileValidation.ExistingOnly )]
public required FileInfo? SomeOtherPath { get; init; }
public override string ToString( )
{
return $"""
SomePath = '{SomePath?.FullName ?? "<null>"}'
Verbosity = {Verbosity}
SomeExistingPath = '{SomeExistingPath?.FullName ?? "<null>"}'
Thing1 = {Thing1}
NotAnOption = {NotAnOption ?? "<null>"}
SomeOtherPath = '{SomeOtherPath?.FullName ?? "<null>"}'
IncludePath = '{string.Join(";", IncludePath.Select(di=>di.FullName))}'
""";
}
}
}