@@ -161,7 +161,7 @@ describe("Command", () => {
161161 yield * MockTerminal . inputKey ( "enter" )
162162 yield * Fiber . join ( fiber )
163163
164- assert . deepStrictEqual ( captured , [ [ "greet" , "--name" , "Alice" , "2" ] ] )
164+ assert . deepStrictEqual ( captured , [ [ "greet" , "--name" , "Alice" , "--" , " 2"] ] )
165165 } ) . pipe ( Effect . provide ( TestLayer ) ) )
166166
167167 it . effect ( "should run wizard-generated arguments with --wizard" , ( ) =>
@@ -361,6 +361,60 @@ describe("Command", () => {
361361 assert . deepStrictEqual ( captured , [ "selected" ] )
362362 } ) . pipe ( Effect . provide ( TestLayer ) ) )
363363
364+ it . effect ( "should replace typed flags and arguments with wizard answers" , ( ) =>
365+ Effect . gen ( function * ( ) {
366+ const captured : Array < readonly [ string , string ] > = [ ]
367+ const command = Command . make ( "demo" , {
368+ name : Flag . String ( "name" ) ,
369+ value : Argument . String ( "value" )
370+ } , ( { name, value } ) => Effect . sync ( ( ) => captured . push ( [ name , value ] ) ) )
371+
372+ const fiber = yield * Command . runWith ( command , { version : "1.0.0" } ) ( [
373+ "--name" ,
374+ "typed" ,
375+ "typed" ,
376+ "--wizard"
377+ ] ) . pipe ( Effect . forkChild )
378+ yield * MockTerminal . inputText ( "prompted" )
379+ yield * MockTerminal . inputKey ( "enter" )
380+ yield * MockTerminal . inputText ( "prompted" )
381+ yield * MockTerminal . inputKey ( "enter" )
382+ yield * MockTerminal . inputKey ( "enter" )
383+ yield * Fiber . join ( fiber )
384+
385+ assert . deepStrictEqual ( captured , [ [ "prompted" , "prompted" ] ] )
386+ } ) . pipe ( Effect . provide ( TestLayer ) ) )
387+
388+ it . effect ( "should preserve inherited clustered flags before a boolean-looking wizard answer" , ( ) =>
389+ Effect . gen ( function * ( ) {
390+ const captured : Array < readonly [ boolean , boolean , string ] > = [ ]
391+ const root = Command . make ( "root" ) . pipe (
392+ Command . withSharedFlags ( {
393+ silent : Flag . Boolean ( "silent" ) . pipe ( Flag . withAlias ( "s" ) ) ,
394+ ipv4 : Flag . Boolean ( "ipv4" ) . pipe ( Flag . withAlias ( "4" ) )
395+ } )
396+ )
397+ const child = Command . make ( "child" , { value : Argument . String ( "value" ) } , ( { value } ) =>
398+ Effect . gen ( function * ( ) {
399+ const { silent, ipv4 } = yield * root
400+ captured . push ( [ silent , ipv4 , value ] )
401+ } ) )
402+ const command = root . pipe ( Command . withSubcommands ( [ child ] ) )
403+
404+ const fiber = yield * Command . runWith ( command , { version : "1.0.0" } ) ( [
405+ "child" ,
406+ "-s4" ,
407+ "typed" ,
408+ "--wizard"
409+ ] ) . pipe ( Effect . forkChild )
410+ yield * MockTerminal . inputText ( "false" )
411+ yield * MockTerminal . inputKey ( "enter" )
412+ yield * MockTerminal . inputKey ( "enter" )
413+ yield * Fiber . join ( fiber )
414+
415+ assert . deepStrictEqual ( captured , [ [ true , true , "false" ] ] )
416+ } ) . pipe ( Effect . provide ( TestLayer ) ) )
417+
364418 it . effect ( "should reject --completions without a shell" , ( ) =>
365419 Effect . gen ( function * ( ) {
366420 let invoked = false
0 commit comments