You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`.WithDescription("Execute operation in silent mode without feedback")` Specify a help description for the option
49
49
50
+
### Parsing Using Fluent Command Line Builder
51
+
52
+
Instead of assigning parsed values to variables you can use the Fluent Command Line Builder to automatically create a defined object type and setup individual Options for each strongly-typed property. Because the builder is simply a wrapper around the parser you can still use the Fluent Command Line Parser Api to define the behaviour for each Option.
53
+
54
+
The Fluent Command Line Builder can build a type and populate the properties with parsed values such as in the following example:
55
+
```
56
+
public class ApplicationArguments
57
+
{
58
+
public int RecordId { get; set; }
59
+
public bool Silent { get; set; }
60
+
public string NewValue { get; set; }
61
+
}
62
+
63
+
static void Main(string[] args)
64
+
{
65
+
// create a builder for the ApplicationArguments type
66
+
var b = new FluentCommandLineBuilder<ApplicationArguments>();
67
+
68
+
// specify which property the value will be assigned too.
69
+
b.Setup(arg => arg.RecordId)
70
+
.As('r', "record") // define the short and long option name
71
+
.Required(); // using the standard fluent Api to declare this Option as required.
72
+
73
+
b.Setup(arg => arg.NewValue)
74
+
.As('v', "value")
75
+
.Required();
76
+
77
+
b.Setup(arg => arg.Silent)
78
+
.As('s', "silent")
79
+
.SetDefault(false); // use the standard fluent Api to define a default value if non is specified in the arguments
80
+
81
+
var result = b.Parse(args);
82
+
83
+
if(result.HasErrors == false)
84
+
{
85
+
// use the instantiated ApplicationArguments object from the Object property on the builder.
86
+
application.Run(b.Object);
87
+
}
88
+
}
89
+
```
90
+
50
91
### Parsing To Collections
51
92
52
93
Many arguments can be collected as part of a list. Types supported are `string`, `int`, `double` and `bool`
0 commit comments