void ParseCommandLine( CmdLine & cl ) { while( cl.Argc() > 1 ) { string sflag = cl.Argv(1); cl.Shift(); FlagName fn = StringToFlag( sflag ); if ( fn == fnNone ) { throw Error( "Invalid command line option: " + sflag ); } pair <bool,int> vals = GetFlagValues( fn ); if ( vals.second ) { if ( cl.Argc() == 1 ) { throw Error( "Missing command line parameter for " + sflag ); } CommandParam = cl.Argv(1); cl.Shift(); } if ( vals.first ) { if ( CommandName != fnNone ) { throw Error( "Only one command option allowed" ); } CommandName = fn; } else { switch( fn ) { case fnExpand: Expand = true; break; case fnForce: CheckExist = false ; break; case fnSys: UseSys = true; break; case fnUnix: Unix = true; break; default: throw Error( "bad option " ); } } } if ( CommandName == fnNone ) { throw Error( "Need one of " + CommandList() ); } }