Skip to content

Commit c93173a

Browse files
committed
2 parents 569314c + e172d87 commit c93173a

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

README.md

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### FSharp.SystemCommandLine
1+
### FSharp.SystemCommandLine (beta5)
22
[![NuGet version (FSharp.SystemCommandLine)](https://img.shields.io/nuget/v/FSharp.SystemCommandLine.svg?style=flat-square)](https://www.nuget.org/packages/FSharp.SystemCommandLine/)
33

44
The purpose of this library is to provide quality of life improvements when using the [`System.CommandLine`](https://github.com/dotnet/command-line-api) API in F#.
@@ -7,10 +7,10 @@ _[Click here to view the old beta 4 README](README-beta4.md)_
77

88
## Features
99

10-
* Mismatches between `inputs` and `setHandler` function parameters are caught at compile time
11-
* `Input.Option` helper method avoids the need to use the `System.CommandLine.Option` type directly (which conflicts with the F# `Option` type)
12-
* `Input.OptionMaybe` and `Input.ArgumentMaybe` methods allow you to use F# `option` types in your handler function.
13-
* `Input.Context` method allows you to pass the `System.CommandLine.Invocation.InvocationContext` to your handler function.
10+
* Mismatches between `inputs` and `setAction` handler function parameters are caught at compile time
11+
* `Input.option` helper avoids the need to use the `System.CommandLine.Option` type directly (which conflicts with the F# `Option` type)
12+
* `Input.optionMaybe` and `Input.argumentMaybe` helpers allow you to use F# `option` types in your handler function.
13+
* `Input.context` helper allows you to pass the `ActionContext` to your action function which is necessary for some operations.
1414

1515
## Examples
1616

@@ -41,7 +41,7 @@ let main argv =
4141
}
4242
```
4343

44-
💥WARNING: You must declare `inputs` before `setHandler` or else the type checking will not work properly and you will get a build error!💥
44+
💥WARNING: You must declare `inputs` before `setAction` or else the type checking will not work properly and you will get a build error!💥
4545

4646
```batch
4747
> unzip.exe "c:\test\stuff.zip"
@@ -52,7 +52,7 @@ let main argv =
5252
```
5353

5454

55-
_Notice that mismatches between the `setHandler` and the `inputs` are caught as a compile time error:_
55+
_Notice that mismatches between the `setAction` and the `inputs` are caught as a compile time error:_
5656
![fs scl demo](https://user-images.githubusercontent.com/1030435/164288239-e0ff595d-cdb2-47f8-9381-50c89aedd481.gif)
5757

5858

@@ -84,7 +84,7 @@ let main argv =
8484
argument "zipfile" |> desc "The file to unzip",
8585
optionMaybe "--output" |> alias "-o" |> desc "The output directory"
8686
)
87-
setHandler unzip
87+
setAction unzip
8888
}
8989
```
9090

@@ -119,7 +119,7 @@ let deleteCmd =
119119
else
120120
printfn $"{dir.FullName} does not exist."
121121
122-
let dir = argument "dir |> desc "The directory to delete"
122+
let dir = argument "dir" |> desc "The directory to delete"
123123
let recursive = option "--recursive" |> def false
124124
125125
command "delete" {
@@ -536,7 +536,7 @@ let main argv =
536536
commandLineConfiguration {
537537
description "Appends words together"
538538
inputs (words, separator)
539-
setHandler app
539+
setAction app
540540
}
541541
542542
let parseResult = cfg.Parse(argv)
@@ -571,11 +571,11 @@ let main argv =
571571
}
572572
```
573573

574-
## Customizing the Default Pipeline
574+
## Command Line Configuration
575575

576-
System.CommandLine has a `CommandLineBuilder` that allows the user to customize various behaviors.
576+
System.CommandLine has a `CommandLineConfiguration` that allows the user to customize various behaviors.
577577

578-
FSharp.SystemCommandLine is configured to use the built-in defaults (via `CommandLineBuilder().UseDefaults()`), but you can easily override them via the `usePipeline` custom operation which gives you access to the `CommandLineBuilder`.
578+
FSharp.SystemCommandLine uses the defaults from `CommandLineConfiguration`, but you can override them via the `configure` custom operation which gives you access to the `CommandLineConfiguration`.
579579

580580
For example, the default behavior intercepts input strings that start with a "@" character via the "TryReplaceToken" feature. This will cause an issue if you need to accept input that starts with "@". Fortunately, you can disable this via `usePipeline`:
581581

@@ -598,7 +598,7 @@ let main argv =
598598
599599
// The package option needs to accept strings that start with "@" symbol.
600600
// For example, "--package @shoelace-style/shoelace".
601-
// To accomplish this, we will need to modify the default pipeline settings below.
601+
// To accomplish this, we will need to modify the configuration below.
602602
let package = option "--package" |> alias "-p" |> desc "A package name that may have a leading '@' character."
603603
604604
rootCommand argv {
@@ -608,11 +608,6 @@ let main argv =
608608
cfg.ResponseFileTokenReplacer <- null
609609
)
610610
inputs package
611-
setHandler app
611+
setAction app
612612
}
613613
```
614-
615-
As you can see, there are a lot of options that can be configured here (note that you need to `open System.CommandLine.Builder`):
616-
617-
![image](https://user-images.githubusercontent.com/1030435/199282781-1800b79c-7638-4242-8ca0-777d7237e20a.png)
618-

0 commit comments

Comments
 (0)