Skip to content

Commit 4667d69

Browse files
committed
Fixed bug where CommandLineConfiguration was ignored.
1 parent 5b3989d commit 4667d69

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/FSharp.SystemCommandLine/CommandBuilders.fs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ type BaseCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>() =
124124
invalidOp "Only 8 inputs are supported."
125125

126126

127-
//member val CommandLineBuilder = CommandLineBuilder().UseDefaults() with get, set
128127
member val CommandLineConfiguration = new CommandLineConfiguration(new RootCommand()) with get, set
129128

130129
member this.Yield _ =
@@ -397,7 +396,7 @@ type RootCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>(args: string ar
397396
|> this.SetHandlerUnit spec
398397
|> addGlobalOptionsToCommand spec.GlobalInputs
399398

400-
CommandLineParser.Parse(rootCommand, args).Invoke()
399+
rootCommand.Parse(args, this.CommandLineConfiguration).Invoke()
401400

402401
/// Executes a Command with a handler that returns int.
403402
member this.Run (spec: CommandSpec<'Inputs, int>) =
@@ -406,8 +405,8 @@ type RootCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>(args: string ar
406405
|> this.SetGeneralProperties spec
407406
|> this.SetHandlerInt spec
408407
|> addGlobalOptionsToCommand spec.GlobalInputs
409-
410-
CommandLineParser.Parse(rootCommand, args).Invoke()
408+
409+
rootCommand.Parse(args, this.CommandLineConfiguration).Invoke()
411410

412411
/// Executes a Command with a handler that returns a Task<unit> or Task<int>.
413412
member this.Run (spec: CommandSpec<'Inputs, Task<unit>>) =
@@ -417,7 +416,7 @@ type RootCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>(args: string ar
417416
|> this.SetHandlerTask spec
418417
|> addGlobalOptionsToCommand spec.GlobalInputs
419418

420-
CommandLineParser.Parse(rootCommand, args).InvokeAsync()
419+
rootCommand.Parse(args, this.CommandLineConfiguration).InvokeAsync()
421420

422421
/// Executes a Command with a handler that returns a Task<unit> or Task<int>.
423422
member this.Run (spec: CommandSpec<'Inputs, Task<int>>) =
@@ -427,7 +426,7 @@ type RootCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>(args: string ar
427426
|> this.SetHandlerTaskInt spec
428427
|> addGlobalOptionsToCommand spec.GlobalInputs
429428

430-
CommandLineParser.Parse(rootCommand, args).InvokeAsync()
429+
rootCommand.Parse(args, this.CommandLineConfiguration).InvokeAsync()
431430

432431

433432
/// Builds a `System.CommandLine.Command`.

src/Tests/SimpleAppTest.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ open Swensen.Unquote
55
open FSharp.SystemCommandLine
66
open Utils
77
open Input
8+
open System.CommandLine.Parsing
89

910
let mutable handlerCalled = false
1011
[<SetUp>]
@@ -92,14 +93,13 @@ let ``05 empty array`` () =
9293
} =! 0
9394

9495
/// In beta5, the action handler is never called if an input starts with "@", even if ResponseFileTokenReplacer is set to null.
95-
[<Test; Ignore "Ignore failing test">]
96+
[<Test>]
9697
let ``06 Token Replacer`` () =
9798
testRootCommand "--package @shoelace-style/shoelace" {
9899
description "Can be called with a leading @ package"
99100
configure (fun cfg ->
100101
// Skip @ processing
101-
//cfg.UseTokenReplacer(fun _ _ _ -> false) // Removed in beta5
102-
cfg.ResponseFileTokenReplacer <- null // in beta5, you must set ResponseFileTokenReplacer to null to skip @ processing
102+
cfg.ResponseFileTokenReplacer <- null
103103
//cfg.ResponseFileTokenReplacer <- new TryReplaceToken(fun _ _ _ -> false)
104104
)
105105
//inputs (Input.Option<string>("package", [ "--package"; "-p" ], "A package with a leading @ name"))

0 commit comments

Comments
 (0)