UnMango.CliWrap.FSharp 0.0.8-alpha.0.6

This is a prerelease version of UnMango.CliWrap.FSharp.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package UnMango.CliWrap.FSharp --version 0.0.8-alpha.0.6                
NuGet\Install-Package UnMango.CliWrap.FSharp -Version 0.0.8-alpha.0.6                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UnMango.CliWrap.FSharp" Version="0.0.8-alpha.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UnMango.CliWrap.FSharp --version 0.0.8-alpha.0.6                
#r "nuget: UnMango.CliWrap.FSharp, 0.0.8-alpha.0.6"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install UnMango.CliWrap.FSharp as a Cake Addin
#addin nuget:?package=UnMango.CliWrap.FSharp&version=0.0.8-alpha.0.6&prerelease

// Install UnMango.CliWrap.FSharp as a Cake Tool
#tool nuget:?package=UnMango.CliWrap.FSharp&version=0.0.8-alpha.0.6&prerelease                

CliWrap.FSharp

Build Codecov GitHub Release NuGet Version NuGet Downloads

Idiomatic F# support for CliWrap.

Install

Usage

Bindings for normal CliWrap commands are available in the Cli module.

let main args = async {
  let! result =
    Cli.wrap "dotnet"
    |> Cli.args [ "build" ]
    |> Cli.workDir "~/src/CliWrap.FSharp"
    |> Cli.exec

  result.ExitCode
}

Cancellation token overloads are available in Cli.Tasks.

let main args = task {
  use cts = new CancellationTokenSource()
  let! result =
    Cli.wrap "dotnet"
    |> Cli.args [ "build" ]
    |> Cli.workDir "~/src/CliWrap.FSharp"
    |> Cli.Task.exec cts.Token

  result.ExitCode
}
let main args = task {
  use graceful = new CancellationTokenSource()
  use forceful = new CancellationTokenSource()
  let! result =
    Cli.wrap "dotnet"
    |> Cli.args [ "build" ]
    |> Cli.workDir "~/src/CliWrap.FSharp"
    |> Cli.Task.execf forceful.Token graceful.Token

  result.ExitCode
}

The core of the package is a simple computation expression that wraps CliWrap.Command. It attempts to mimic the builder pattern and .With* style methods.

let main args =
  let cmd = command "dotnet" {
    args = [ "build" ]
    workingDirectory = "~/src/CliWrap.FSharp"
  }

  cmd.ExecuteAsync()

The computation expression also supports executing the command with exec.

let main args = task {
  let! result = command "dotnet" {
    args = [ "build" ]
    workingDirectory = "~/src/CliWrap.FSharp"
    exec
  }

  result.ExitCode
}

Cancellation is also supported.

let main args = task {
  use cts = new CancellationTokenSource()
  let! result = command "dotnet" {
    args = [ "build" ]
    workingDirectory = "~/src/CliWrap.FSharp"
    exec cts.Token
  }

  result.ExitCode
}

CliWrap's buffered execution is supported with buffered.

let main args = task {
  use cts = new CancellationTokenSource()
  let! result = command "dotnet" {
    args = [ "build" ]
    workingDirectory = "~/src/CliWrap.FSharp"
    buffered Encoding.UTF8 cts.Token
  }

  result.ExitCode
}

Asynchrony with F#'s Async<'T> is supported with async.

let main args = async {
  use cts = new CancellationTokenSource()
  let! result = command "dotnet" {
    args = [ "build" ]
    workingDirectory = "~/src/CliWrap.FSharp"
    async cts.Token
  }

  result.ExitCode
}

CliWrap's piping functionality is supported via the pipeline computation expression.

let main args =
  let cmd = pipeline {
    "an inline string source"
    Cli.wrap "echo"
  }

  cmd.ExecuteAsync()

Limited support for piping is available with |>>.

let main args =
  let cmd = Cli.wrap "yes" |>> Cli.wrap "echo"

  cmd.ExecuteAsync()

Inspirations

The idea to abuse F# computation expressions was inspired by Akkling.Hocon and FsHttp.

Obviously CliWrap was a big inspiration for this package.

Q/A

Idiomatic? This looks nothing like the F# I write!

If something looks off please open an issue! I've only recently been diving further into the F# ecosystem.

Why not paket?

If renovate ever supports it!

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.8-alpha.0.8 0 11/14/2024
0.0.8-alpha.0.7 25 11/13/2024
0.0.8-alpha.0.6 27 11/12/2024
0.0.8-alpha.0.5 28 11/7/2024
0.0.8-alpha.0.4 37 11/2/2024
0.0.8-alpha.0.3 35 10/29/2024
0.0.8-alpha.0.2 33 10/25/2024
0.0.8-alpha.0.1 31 10/25/2024
0.0.7 125 10/23/2024
0.0.7-alpha.0.41 33 10/23/2024
0.0.7-alpha.0.40 30 10/23/2024
0.0.7-alpha.0.39 28 10/23/2024
0.0.7-alpha.0.38 39 10/16/2024
0.0.7-alpha.0.37 47 10/2/2024
0.0.7-alpha.0.36 43 9/30/2024
0.0.7-alpha.0.35 48 9/27/2024
0.0.7-alpha.0.34 39 9/25/2024
0.0.7-alpha.0.33 41 9/24/2024
0.0.7-alpha.0.32 45 9/23/2024
0.0.7-alpha.0.31 66 9/19/2024
0.0.7-alpha.0.30 75 9/17/2024
0.0.7-alpha.0.29 54 9/14/2024
0.0.7-alpha.0.28 48 9/13/2024
0.0.7-alpha.0.27 54 9/10/2024
0.0.7-alpha.0.26 86 9/7/2024
0.0.7-alpha.0.25 52 9/7/2024
0.0.7-alpha.0.24 52 9/6/2024
0.0.7-alpha.0.23 56 9/5/2024
0.0.7-alpha.0.22 53 9/5/2024
0.0.7-alpha.0.21 52 9/5/2024
0.0.7-alpha.0.20 58 9/5/2024
0.0.7-alpha.0.19 54 9/5/2024
0.0.7-alpha.0.18 51 9/5/2024
0.0.7-alpha.0.17 60 9/4/2024
0.0.7-alpha.0.16 537 7/12/2024
0.0.7-alpha.0.15 63 7/10/2024
0.0.7-alpha.0.14 59 7/8/2024
0.0.7-alpha.0.13 440 6/12/2024
0.0.7-alpha.0.12 83 6/10/2024
0.0.7-alpha.0.11 188 6/6/2024
0.0.7-alpha.0.10 128 6/2/2024
0.0.7-alpha.0.9 57 6/2/2024
0.0.7-alpha.0.8 54 6/2/2024
0.0.7-alpha.0.7 53 6/2/2024
0.0.7-alpha.0.6 48 6/2/2024
0.0.7-alpha.0.5 54 6/2/2024
0.0.7-alpha.0.4 54 6/2/2024
0.0.7-alpha.0.3 48 6/2/2024
0.0.7-alpha.0.2 173 3/16/2024
0.0.7-alpha.0.1 61 3/16/2024
0.0.6 151 3/4/2024
0.0.6-alpha.0.13 60 3/4/2024
0.0.6-alpha.0.12 51 3/4/2024
0.0.6-alpha.0.11 51 3/4/2024
0.0.6-alpha.0.10 55 3/4/2024
0.0.6-alpha.0.9 54 3/4/2024
0.0.6-alpha.0.8 57 3/4/2024
0.0.6-alpha.0.7 58 3/4/2024
0.0.6-alpha.0.6 58 1/31/2024
0.0.6-alpha.0.5 57 1/24/2024
0.0.6-alpha.0.4 55 1/22/2024
0.0.6-alpha.0.3 58 1/18/2024
0.0.6-alpha.0.2 53 1/18/2024
0.0.6-alpha.0.1 50 1/18/2024
0.0.5 129 1/14/2024
0.0.5-alpha.0.2 55 1/14/2024
0.0.5-alpha.0.1 55 1/14/2024
0.0.4 124 1/14/2024
0.0.3-alpha.1 61 1/14/2024
0.0.3-alpha 91 1/14/2024
0.0.2-alpha.1 52 1/13/2024
0.0.2-alpha 98 1/13/2024
0.0.1-alpha.3 61 1/13/2024
0.0.1-alpha.2 71 1/13/2024