This release brings FSharp.SystemCommandLine up to date with the new v2.0.0-beta7 of System.CommandLine.
Changes
- BREAKING: The
commandLineConfigurationcomputation expression has been removed (becauseSystem.CommandLine.CommandLineConfigurationhas been removed). - A new
ManualInvocation.rootCommandhas been added. Unlike the defaultrootCommandwhich is automatically executes, this simply returns aSystem.CommandLine.RootCommandfor you to manually invoke:
module Global =
let enableLogging = option "--enable-logging" |> recursive
let zipCmd =
command "zip" {
description "Zips a directory."
inputs (argument "directory" |> validateDirectoryExists)
setAction (fun dir -> async { ... })
}
let unzipCmd =
command "unzip" {
description "Unzips a directory."
inputs (argument "directory" |> validateDirectoryExists)
setAction (fun dir -> async { ... })
}
let main (argv: string[]) =
let cmd =
ManualInvocation.rootCommand {
description "Zip or Unzip a Directory"
noActionAsync
addInputs Global.options
addCommands [ zipCmd; unzipCmd ]
}
let parseResult = cmd.Parse(argv)
let loggingEnabled = Global.enableLogging.GetValue parseResult
printfn $"Logging enabled: {loggingEnabled}"
parseResult.InvokeAsync()
|> Async.AwaitTask
|> Async.RunSynchronouslyconfigure(inrootCommand) has been deprecated.configureParserhas been added torootCommandand the newManualInvocation.rootCommand.configureInvocationhas been added torootCommand.