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
[](https://gitter.im/gsscoder/commandline?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5
6
6
7
Command Line Parser Library 2.0.275.0 beta for CLR.
7
8
===
9
+
8
10
The Command Line Parser Library offers CLR applications a clean and concise API for manipulating command line arguments and related tasks, such as defining switches, options and verb commands. It allows you to display a help screen with a high degree of customization and a simple way to report syntax errors to the end user.
9
11
10
12
Everything that is boring and repetitive about parsing command line arguments is delegated to the library, letting developers concentrate on core logic. It's written in **C#** and doesn't depend on other packages.
@@ -82,8 +84,7 @@ class Options {
82
84
83
85
[Value(0, MetaName="offset",
84
86
HelpText="File offset.")]
85
-
publiclong? Offset { get; set;}
86
-
}
87
+
publiclong? Offset { get; set; }
87
88
}
88
89
```
89
90
Consume them:
@@ -146,6 +147,35 @@ int Main(string[] args) {
146
147
}
147
148
```
148
149
150
+
**F#:**
151
+
```fsharp
152
+
open CommandLine
153
+
154
+
[<Verb("add", HelpText = "Add file contents to the index.")>]
155
+
type AddOptions = {
156
+
// normal options here
157
+
}
158
+
[<Verb("commit", HelpText = "Record changes to the repository.")>]
159
+
type CommitOptions = {
160
+
// normal options here
161
+
}
162
+
[<Verb("clone", HelpText = "Clone a repository into a new directory.")>]
163
+
type CloneOptions = {
164
+
// normal options here
165
+
}
166
+
167
+
[<EntryPoint>]
168
+
let main args =
169
+
let result = Parser.Default.ParseArguments<AddOptions, CommitOptions, CloneOptions> args
170
+
match result with
171
+
| :? CommandLine.Parsed<obj> as command ->
172
+
match command.Value with
173
+
| :? AddOptions as opts -> RunAddAndReturnExitCode opts
174
+
| :? CommitOptions as opts -> RunCommitAndReturnExitCode opts
175
+
| :? CloneOptions as opts -> RunCloneAndReturnExitCode opts
0 commit comments