Skip to content

Commit 8d65041

Browse files
authored
Added readme example of getting global option value from ParseResult.
1 parent b594bf2 commit 8d65041

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,23 @@ let ioCmd =
389389
390390
[<EntryPoint>]
391391
let main argv =
392-
rootCommand argv {
393-
description "Sample app for System.CommandLine"
394-
setHandler id
395-
addCommand ioCmd
396-
}
392+
let ctx = Input.Context()
393+
394+
let parser =
395+
rootCommandParser {
396+
description "Sample app for System.CommandLine"
397+
setHandler id
398+
addGlobalOptions Global.options
399+
addCommand ioCmd
400+
}
401+
402+
let parseResult = parser.Parse(argv)
403+
404+
// Get global option value from the parseResult
405+
let loggingEnabled = Global.enableLogging.GetValue parseResult
406+
printfn $"ROOT: Logging enabled: {loggingEnabled}"
407+
408+
parseResult.Invoke()
397409
```
398410

399411
### Database Migrations Example

0 commit comments

Comments
 (0)