BadScript 2
Loading...
Searching...
No Matches
NameExtensions.cs
Go to the documentation of this file.
1// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
2
3using System;
4
5namespace CommandLine.Core
6{
7 internal static class NameExtensions
8 {
9 public static bool MatchName(this string value, string shortName, string longName, StringComparer comparer)
10 {
11 return value.Length == 1
12 ? comparer.Equals(value, shortName)
13 : comparer.Equals(value, longName);
14 }
15
16 public static NameInfo FromOptionSpecification(this OptionSpecification specification)
17 {
18 return new NameInfo(specification.ShortName,
19 specification.LongName
20 );
21 }
22
23 public static NameInfo FromSpecification(this Specification specification)
24 {
25 switch (specification.Tag)
26 {
27 case SpecificationType.Option:
28 return FromOptionSpecification((OptionSpecification)specification);
29 default:
30 return NameInfo.EmptyName;
31 }
32 }
33 }
34}
static NameInfo FromOptionSpecification(this OptionSpecification specification)
static NameInfo FromSpecification(this Specification specification)
static bool MatchName(this string value, string shortName, string longName, StringComparer comparer)
Models name information, used in CommandLine.Error instances.
Definition NameInfo.cs:11
static readonly NameInfo EmptyName
Represents an empty name information. Used when CommandLine.Error are tied to values,...
Definition NameInfo.cs:16