Skip to content

Commit a84134f

Browse files
committed
Add manual console test for the token replacer
1 parent 815a09a commit a84134f

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module ProgramTokenReplacer
2+
3+
open FSharp.SystemCommandLine
4+
open System.CommandLine.Parsing
5+
6+
let app (package: string) =
7+
if package.StartsWith("@") then
8+
printfn $"{package}"
9+
0
10+
else
11+
eprintfn "The package name does not start with a leading @"
12+
1
13+
14+
//[<EntryPoint>]
15+
let main argv =
16+
let package =
17+
Input.Option([ "--package"; "-p" ], "A package with a leading @ name")
18+
19+
rootCommand argv {
20+
description "Can be called with a leading @ package"
21+
22+
useTokenReplacer (
23+
// in this case we want to skip @ processing
24+
TryReplaceToken (fun _ _ _ -> false)
25+
)
26+
27+
inputs package
28+
setHandler app
29+
}

src/TestConsole/Properties/launchSettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"TestConsole": {
44
"commandName": "Project",
55
"commandLineArgs": "-w hello -w world"
6+
},
7+
"Leading @": {
8+
"commandName": "Project",
9+
"commandLineArgs": "--package @shoelace-style/shoelace"
610
}
711
}
812
}

src/TestConsole/TestConsole.fsproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
<Compile Include="ProgramSubCommand.fs" />
1313
<Compile Include="ProgramTask.fs" />
1414
<Compile Include="Program.fs" />
15+
<Compile Include="ProgramTokenReplacer.fs" />
1516
</ItemGroup>
1617

17-
<ItemGroup />
18-
1918
<ItemGroup>
2019
<ProjectReference Include="..\FSharp.SystemCommandLine\FSharp.SystemCommandLine.fsproj" />
2120
</ItemGroup>

0 commit comments

Comments
 (0)