You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-20Lines changed: 15 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
### FSharp.SystemCommandLine
1
+
### FSharp.SystemCommandLine (beta5)
2
2
[](https://www.nuget.org/packages/FSharp.SystemCommandLine/)
3
3
4
4
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)_
7
7
8
8
## Features
9
9
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.
14
14
15
15
## Examples
16
16
@@ -41,7 +41,7 @@ let main argv =
41
41
}
42
42
```
43
43
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!💥
45
45
46
46
```batch
47
47
> unzip.exe "c:\test\stuff.zip"
@@ -52,7 +52,7 @@ let main argv =
52
52
```
53
53
54
54
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:_
optionMaybe "--output" |> alias "-o" |> desc "The output directory"
86
86
)
87
-
setHandler unzip
87
+
setAction unzip
88
88
}
89
89
```
90
90
@@ -119,7 +119,7 @@ let deleteCmd =
119
119
else
120
120
printfn $"{dir.FullName} does not exist."
121
121
122
-
let dir = argument "dir |> desc "The directory to delete"
122
+
let dir = argument "dir" |> desc "The directory to delete"
123
123
let recursive = option "--recursive" |> def false
124
124
125
125
command "delete" {
@@ -536,7 +536,7 @@ let main argv =
536
536
commandLineConfiguration {
537
537
description "Appends words together"
538
538
inputs (words, separator)
539
-
setHandler app
539
+
setAction app
540
540
}
541
541
542
542
let parseResult = cfg.Parse(argv)
@@ -571,11 +571,11 @@ let main argv =
571
571
}
572
572
```
573
573
574
-
## Customizing the Default Pipeline
574
+
## Command Line Configuration
575
575
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.
577
577
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`.
579
579
580
580
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`:
581
581
@@ -598,7 +598,7 @@ let main argv =
598
598
599
599
// The package option needs to accept strings that start with "@" symbol.
600
600
// 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.
602
602
let package = option "--package" |> alias "-p" |> desc "A package name that may have a leading '@' character."
603
603
604
604
rootCommand argv {
@@ -608,11 +608,6 @@ let main argv =
608
608
cfg.ResponseFileTokenReplacer <- null
609
609
)
610
610
inputs package
611
-
setHandler app
611
+
setAction app
612
612
}
613
613
```
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`):
0 commit comments