@@ -243,6 +243,47 @@ describe("hoistParentOptionsBeforeSubcommand", () => {
243243 ] ) ;
244244 } ) ;
245245
246+ it ( "does not hoist a bare value option with no following value" , ( ) => {
247+ const { browser, tabs } = buildBrowserTree ( ) ;
248+ const argv = [ "node" , "openclaw" , "browser" , "tabs" , "--browser-profile" ] ;
249+ expect (
250+ hoistParentOptionsBeforeSubcommand ( {
251+ argv,
252+ parentCommand : browser ,
253+ subcommandName : "tabs" ,
254+ subcommandCommand : tabs ,
255+ } ) ,
256+ ) . toEqual ( argv ) ;
257+ } ) ;
258+
259+ it ( "does not hoist a value option followed by another flag" , ( ) => {
260+ // The bare `--browser-profile` (no following value) is left in place so the
261+ // missing-value error is preserved; the trailing `--json` is a valid parent
262+ // boolean option and is still hoisted before the subcommand.
263+ const { browser, tabs } = buildBrowserTree ( ) ;
264+ expect (
265+ hoistParentOptionsBeforeSubcommand ( {
266+ argv : [ "node" , "openclaw" , "browser" , "tabs" , "--browser-profile" , "--json" ] ,
267+ parentCommand : browser ,
268+ subcommandName : "tabs" ,
269+ subcommandCommand : tabs ,
270+ } ) ,
271+ ) . toEqual ( [ "node" , "openclaw" , "browser" , "--json" , "tabs" , "--browser-profile" ] ) ;
272+ } ) ;
273+
274+ it ( "does not hoist an empty --flag= form" , ( ) => {
275+ const { browser, tabs } = buildBrowserTree ( ) ;
276+ const argv = [ "node" , "openclaw" , "browser" , "tabs" , "--browser-profile=" ] ;
277+ expect (
278+ hoistParentOptionsBeforeSubcommand ( {
279+ argv,
280+ parentCommand : browser ,
281+ subcommandName : "tabs" ,
282+ subcommandCommand : tabs ,
283+ } ) ,
284+ ) . toEqual ( argv ) ;
285+ } ) ;
286+
246287 it ( "returns argv unchanged when the parent command is the root" , ( ) => {
247288 const root = new Command ( ) . name ( "openclaw" ) . option ( "--json" , "" , false ) ;
248289 root . command ( "status" ) ;
0 commit comments