File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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}
Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments