forked from commandlineparser/commandline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNameExtensions.cs
More file actions
34 lines (30 loc) · 1.13 KB
/
NameExtensions.cs
File metadata and controls
34 lines (30 loc) · 1.13 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
// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
using System;
namespace CommandLine.Core
{
static class NameExtensions
{
public static bool MatchName(this string value, string shortName, string longName, StringComparer comparer)
{
return value.Length == 1
? comparer.Equals(value, shortName)
: comparer.Equals(value, longName);
}
public static NameInfo FromOptionSpecification(this OptionSpecification specification)
{
return new NameInfo(
specification.ShortName,
specification.LongName);
}
public static NameInfo FromSpecification(this Specification specification)
{
switch (specification.Tag)
{
case SpecificationType.Option:
return FromOptionSpecification((OptionSpecification)specification);
default:
return NameInfo.EmptyName;
}
}
}
}