Skip to content

Commit 6373ddb

Browse files
committed
Merge pull request #284 from ForNeVeR/patch-1
Readme: add F# example for verbs
2 parents 33ef667 + 0ae5d67 commit 6373ddb

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,35 @@ int Main(string[] args) {
145145
}
146146
```
147147

148+
**F#:**
149+
```fsharp
150+
open CommandLine
151+
152+
[<Verb("add", HelpText = "Add file contents to the index.")>]
153+
type AddOptions = {
154+
// normal options here
155+
}
156+
[<Verb("commit", HelpText = "Record changes to the repository.")>]
157+
type CommitOptions = {
158+
// normal options here
159+
}
160+
[<Verb("clone", HelpText = "Clone a repository into a new directory.")>]
161+
type CloneOptions = {
162+
// normal options here
163+
}
164+
165+
[<EntryPoint>]
166+
let main args =
167+
let result = Parser.Default.ParseArguments<AddOptions, CommitOptions, CloneOptions> args
168+
match result with
169+
| :? CommandLine.Parsed<obj> as command ->
170+
match command.Value with
171+
| :? AddOptions as opts -> RunAddAndReturnExitCode opts
172+
| :? CommitOptions as opts -> RunCommitAndReturnExitCode opts
173+
| :? CloneOptions as opts -> RunCloneAndReturnExitCode opts
174+
| :? CommandLine.NotParsed<obj> -> 1
175+
```
176+
148177
Acknowledgements:
149178
---
150179
[![Jet Brains ReSharper](/art/resharper-logo.png)](http://www.jetbrains.com/resharper/)

0 commit comments

Comments
 (0)