Skip to content

Commit 5144078

Browse files
committed
chore(readme): added example at end in details
1 parent 804d34b commit 5144078

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,42 @@ Notes about invocation:
784784

785785
</details>
786786

787+
<details>
788+
<summary><b>Mapping to a bound set of typed values</b></summary>
789+
790+
Use `Input.mapFromAmong` to map string inputs to typed values:
791+
792+
```F#
793+
open FSharp.SystemCommandLine
794+
type Configuration =
795+
| Debug
796+
| Release
797+
798+
let config =
799+
Input.option<Configuration>
800+
|> Input.mapFromAmong [
801+
"r", Release; "release", Release
802+
"R", Release; "Release", Release
803+
"d", Debug; "debug", Debug
804+
"D", Debug; "Debug", Debug
805+
]
806+
// is required unless you provide a default
807+
808+
// use `Input.mapFromAmongWith` to pass a custom string comparer!
809+
810+
let config =
811+
Input.option<Configuration>
812+
|> Input.mapFromAmongWith StringComparer.OrdinalIgnoreCase [
813+
"r", Release; "release", Release
814+
"d", Debug; "debug", Debug
815+
]
816+
```
817+
818+
Notes about overriding properties:
819+
* `Input.tryParse` will overwrite the configuration from `.mapFromAmong` if it is used downstream.
820+
821+
</details>
822+
787823
---
788824

789825
## Configuration

0 commit comments

Comments
 (0)