@@ -36,15 +36,16 @@ interface Options extends ParsedOptions {
3636}
3737
3838// TODO export this from madwizard
39- type Task = "guide" | "plan"
39+ type Task = "profile" | " guide" | "plan"
4040
41- function withFilepath (
41+ function doMadwizard (
4242 readonly : boolean ,
4343 task : Task ,
44- cb : ( filepath : string , tab : Tab ) => Promise < true | ReactResponse [ "react" ] >
44+ withFilepath = false ,
45+ cb ?: ( filepath : string , tab : Tab ) => Promise < true | ReactResponse [ "react" ] >
4546) {
4647 return async ( { tab, argvNoOptions, parsedOptions } : Arguments < Options > ) => {
47- if ( ! argvNoOptions [ 1 ] ) {
48+ if ( withFilepath && ! argvNoOptions [ 1 ] ) {
4849 argvNoOptions . push ( "ml/codeflare" )
4950 }
5051
@@ -76,8 +77,12 @@ function withFilepath(
7677 const { setTabReadonly } = await import ( "./util" )
7778 setTabReadonly ( { tab } )
7879 }
79- return {
80- react : await cb ( argvNoOptions [ 1 ] , tab ) ,
80+ if ( cb ) {
81+ return {
82+ react : await cb ( argvNoOptions [ 1 ] , tab ) ,
83+ }
84+ } else {
85+ return true
8186 }
8287 }
8388}
@@ -89,25 +94,27 @@ export default function registerMadwizardCommands(registrar: Registrar) {
8994 alias : { quiet : [ "q" ] , interactive : [ "i" ] } ,
9095 }
9196
97+ registrar . listen ( "/profile" , doMadwizard ( true , "profile" ) )
98+
9299 registrar . listen (
93100 "/guide" ,
94- withFilepath ( true , "guide" , ( filepath , tab ) =>
101+ doMadwizard ( true , "guide" , true , ( filepath , tab ) =>
95102 import ( "./components/PlanAndGuide" ) . then ( ( _ ) => _ . planAndGuide ( filepath , { tab } ) )
96103 ) ,
97104 { outputOnly : true , flags }
98105 )
99106
100107 registrar . listen (
101108 "/wizard" ,
102- withFilepath ( false , "guide" , ( filepath , tab ) =>
109+ doMadwizard ( false , "guide" , true , ( filepath , tab ) =>
103110 import ( "./components/Guide" ) . then ( ( _ ) => _ . guide ( filepath , { tab } ) )
104111 ) ,
105112 { flags }
106113 )
107114
108115 registrar . listen (
109116 "/plan" ,
110- withFilepath ( false , "plan" , ( filepath ) => import ( "./components/Plan" ) . then ( ( _ ) => _ . plan ( filepath ) ) ) ,
117+ doMadwizard ( false , "plan" , true , ( filepath ) => import ( "./components/Plan" ) . then ( ( _ ) => _ . plan ( filepath ) ) ) ,
111118 { flags }
112119 )
113120}
0 commit comments