Skip to content

v2.0.0-beta7

Latest

Choose a tag to compare

@JordanMarr JordanMarr released this 17 Aug 15:12
· 1 commit to main since this release
5050816

This release brings FSharp.SystemCommandLine up to date with the new v2.0.0-beta7 of System.CommandLine.

Changes

  • BREAKING: The commandLineConfiguration computation expression has been removed (because System.CommandLine.CommandLineConfiguration has been removed).
  • A new ManualInvocation.rootCommand has been added. Unlike the default rootCommand which is automatically executes, this simply returns a System.CommandLine.RootCommand for 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.RunSynchronously
  • configure (in rootCommand) has been deprecated.
  • configureParser has been added to rootCommand and the new ManualInvocation.rootCommand.
  • configureInvocation has been added to rootCommand.