-
-
Notifications
You must be signed in to change notification settings - Fork 5
Add custom operation useTokenReplacer
#10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
any string that starts with `@` will be processed by SCL dotnet/command-line-api#1750
I wasn't aware of this feature, but I can see how this came up as an issue for Pearla. |
Haven't had my morning coffee yet, but after playing with your changes I just remembered that there is a module ProgramTokenReplacer
open FSharp.SystemCommandLine
open System.CommandLine.Builder
let app (package: string) =
if package.StartsWith("@") then
printfn $"{package}"
0
else
eprintfn "The package name does not start with a leading @"
1
[<EntryPoint>]
let main argv =
let package = Input.Option([ "--package"; "-p" ], "A package with a leading @ name")
rootCommand argv {
description "Can be called with a leading @ package"
usePipeline (fun builder ->
// Skip @ processing
builder.UseTokenReplacer(fun _ _ _ -> false)
)
inputs package
setHandler app
} But I wonder if it would be worth adding something along the lines of module ProgramTokenReplacer
open FSharp.SystemCommandLine
let app (package: string) =
if package.StartsWith("@") then
printfn $"{package}"
0
else
eprintfn "The package name does not start with a leading @"
1
[<EntryPoint>]
let main argv =
let package = Input.Option([ "--package"; "-p" ], "A package with a leading @ name")
rootCommand argv {
description "Can be called with a leading @ package"
disableTokenReplacer
inputs package
setHandler app
}
|
Oh my... I didn't realize that was the intended use case for the pipeline my bad 😅! in that case then I don't think |
There was really no way for you to know. In fact, as I look at the readme, |
Added a section on customizing the pipeline with your example (as that may be an issue for someone else in the future): |
This adds a custom operation to allow us to by-pass a new SCL feature that takes any prefixed
@
strings with certain configuration files more info hereI got some pointers from Chet to add a
TryReplaceToken
delegate so skip this token processingI wasn't sure how to add a rootCommandTest for this change because it initializes a parser in the helper itself and the parser has to also have a
TryReplaceToken
delegate for it to work properly, so I added a manual test in the TestConsole project