-
-
Notifications
You must be signed in to change notification settings - Fork 254
/
SubcommandAttribute.cs
40 lines (34 loc) · 1.17 KB
/
SubcommandAttribute.cs
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
// Copyright (c) Nate McMaster.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
#pragma warning disable 618
namespace McMaster.Extensions.CommandLineUtils
{
/// <summary>
/// Represents a subcommand.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class SubcommandAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of <see cref="SubcommandAttribute" />.
/// </summary>
/// <param name="subcommands">The subcommand types.</param>
public SubcommandAttribute(params Type[] subcommands)
{
if (subcommands == null)
{
throw new ArgumentNullException(nameof(subcommands));
}
if (subcommands.Length == 0)
{
throw new ArgumentException("Value cannot be an empty collection.", nameof(subcommands));
}
Types = subcommands;
}
/// <summary>
/// The types of the subcommands.
/// </summary>
public Type[] Types { get; private set; }
}
}