UnMango.CliWrap.FSharp
0.0.9
dotnet add package UnMango.CliWrap.FSharp --version 0.0.9
NuGet\Install-Package UnMango.CliWrap.FSharp -Version 0.0.9
<PackageReference Include="UnMango.CliWrap.FSharp" Version="0.0.9" />
paket add UnMango.CliWrap.FSharp --version 0.0.9
#r "nuget: UnMango.CliWrap.FSharp, 0.0.9"
// Install UnMango.CliWrap.FSharp as a Cake Addin #addin nuget:?package=UnMango.CliWrap.FSharp&version=0.0.9 // Install UnMango.CliWrap.FSharp as a Cake Tool #tool nuget:?package=UnMango.CliWrap.FSharp&version=0.0.9
CliWrap.FSharp
Idiomatic F# support for CliWrap.
Install
- NuGet:
dotnet add package UnMango.CliWrap.FSharp
- GitHub Packages:
dotnet add package UnMango.CliWrap.FSharp -s github
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
return 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
return 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
return 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
}
return 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
}
return 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
}
return 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
}
return 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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- CliWrap (>= 3.7.1)
- FSharp.Core (>= 9.0.101)
-
.NETStandard 2.1
- CliWrap (>= 3.7.1)
- FSharp.Core (>= 9.0.101)
-
net8.0
- CliWrap (>= 3.7.1)
- FSharp.Core (>= 9.0.101)
-
net9.0
- CliWrap (>= 3.7.1)
- FSharp.Core (>= 9.0.101)
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.9 | 27 | 1/26/2025 |
0.0.9-alpha.0.6 | 27 | 1/26/2025 |
0.0.9-alpha.0.5 | 26 | 1/26/2025 |
0.0.9-alpha.0.4 | 32 | 1/23/2025 |
0.0.9-alpha.0.3 | 33 | 1/22/2025 |
0.0.9-alpha.0.2 | 32 | 1/20/2025 |
0.0.9-alpha.0.1 | 29 | 1/17/2025 |
0.0.8 | 76 | 1/17/2025 |
0.0.8-alpha.0.13 | 31 | 1/17/2025 |
0.0.8-alpha.0.8 | 53 | 11/14/2024 |
0.0.8-alpha.0.7 | 58 | 11/13/2024 |
0.0.8-alpha.0.6 | 56 | 11/12/2024 |
0.0.8-alpha.0.5 | 45 | 11/7/2024 |
0.0.8-alpha.0.4 | 53 | 11/2/2024 |
0.0.8-alpha.0.3 | 52 | 10/29/2024 |
0.0.8-alpha.0.2 | 49 | 10/25/2024 |
0.0.8-alpha.0.1 | 50 | 10/25/2024 |
0.0.7 | 156 | 10/23/2024 |
0.0.6 | 161 | 3/4/2024 |
0.0.5 | 139 | 1/14/2024 |
0.0.4 | 136 | 1/14/2024 |
0.0.3-alpha | 99 | 1/14/2024 |
0.0.2-alpha | 106 | 1/13/2024 |