BadScript 2
Loading...
Searching...
No Matches
ValueSpecification.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;
4using System.Collections.Generic;
5
6using CSharpx;
7
8namespace CommandLine.Core
9{
10 internal sealed class ValueSpecification : Specification
11 {
12 public ValueSpecification(int index,
13 string metaName,
14 bool required,
15 Maybe<int> min,
16 Maybe<int> max,
17 Maybe<object> defaultValue,
18 string helpText,
19 string metaValue,
20 IEnumerable<string> enumValues,
21 Type conversionType,
22 TargetType targetType,
23 bool hidden = false)
25 required,
26 min,
27 max,
28 defaultValue,
29 helpText,
30 metaValue,
31 enumValues,
32 conversionType,
33 targetType,
34 hidden
35 )
36 {
37 Index = index;
38 MetaName = metaName;
39 }
40
41 public int Index { get; }
42
43 public string MetaName { get; }
44
46 Type conversionType,
47 IEnumerable<string> enumValues)
48 {
49 return new ValueSpecification(attribute.Index,
50 attribute.MetaName,
51 attribute.Required,
52 attribute.Min == -1 ? Maybe.Nothing<int>() : Maybe.Just(attribute.Min),
53 attribute.Max == -1 ? Maybe.Nothing<int>() : Maybe.Just(attribute.Max),
54 attribute.Default.ToMaybe(),
55 attribute.HelpText,
56 attribute.MetaValue,
57 enumValues,
58 conversionType,
59 conversionType.ToTargetType(),
60 attribute.Hidden
61 );
62 }
63 }
64}
The Maybe type models an optional value. A value of type Maybe a either contains a value of type a (r...
Definition Maybe.cs:33
int Min
When applied to System.Collections.Generic.IEnumerable<T> properties defines the lower range of items...
bool Required
Gets or sets a value indicating whether a command line option is required.
string MetaValue
Gets or sets mapped property meta value. Usually an uppercase hint of required value type.
int Max
When applied to System.Collections.Generic.IEnumerable<T> properties defines the upper range of items...
string HelpText
Gets or sets a short description of this command line option. Usually a sentence summary.
object Default
Gets or sets mapped property default value.
static ValueSpecification FromAttribute(ValueAttribute attribute, Type conversionType, IEnumerable< string > enumValues)
ValueSpecification(int index, string metaName, bool required, Maybe< int > min, Maybe< int > max, Maybe< object > defaultValue, string helpText, string metaValue, IEnumerable< string > enumValues, Type conversionType, TargetType targetType, bool hidden=false)
Models an value specification, or better how to handle values not bound to options.
int Index
Gets the position this option has on the command line.
string MetaName
Gets or sets name of this positional value specification.