File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -344,8 +344,18 @@ namespace cli
344344 {
345345 if ( cmdLine[ 0 ] == Name () )
346346 {
347- session.Current ( this );
348- return true ;
347+ if ( cmdLine.size () == 1 )
348+ {
349+ session.Current ( this );
350+ return true ;
351+ }
352+ else
353+ {
354+ // check also for subcommands
355+ std::vector<std::string > subCmdLine ( cmdLine.begin ()+1 , cmdLine.end () );
356+ for ( auto & cmd: cmds )
357+ if ( cmd -> Exec ( subCmdLine, session ) ) return true ;
358+ }
349359 }
350360 return false ;
351361 }
Original file line number Diff line number Diff line change @@ -62,6 +62,14 @@ int main()
6262 " hello" ,
6363 [](std::ostream& out){ out << " Hello, submenu world\n " ; },
6464 " Print hello world in the submenu" );
65+
66+ auto subSubMenu = make_unique< Menu >( " subsub" );
67+ subSubMenu -> Add (
68+ " hello" ,
69+ [](std::ostream& out){ out << " Hello, subsubmenu world\n " ; },
70+ " Print hello world in the sub-submenu" );
71+ subMenu -> Add ( std::move (subSubMenu));
72+
6573 rootMenu -> Add ( std::move (subMenu) );
6674
6775
You can’t perform that action at this time.
0 commit comments