virtual void usage ( CmdLineInterface& c ) { int iML = 30; cout << "Basic usage : " << endl; cout << " "<< c.getProgramName() << " [options ] IMG" << endl; cout << endl <<"All options : " << endl; list<Arg*> args = c.getArgList(); for ( ArgListIterator it = args.begin(); it != args.end(); it++ ) { string aL = ( *it )->longID(); string aD = ( *it )->getDescription(); // replace tabs by n spaces. size_t p = aD.find_first_of ( "\t" ); while ( p != string::npos ) { string aD1 = aD.substr ( 0, p ); string aD2 = aD.substr ( p+1, aD.size() - p + 1 ); aD = aD1 + "\n" + string ( iML, ' ' ) + aD2; p = aD.find_first_of ( "\t" ); } if ( (int)aL.size() > iML ) { cout << aL << endl << string ( iML, ' ' ) << aD << endl; } else { cout << aL << string ( iML - aL.size(), ' ' ) << aD << endl; } } }
void NiceCmdLineOutput::printShortUsage(CmdLineInterface& cli, std::ostream& outStream) const { string shortUsage = getBinaryName() + " "; // Print XOR arguments TCLAP::XorHandler xorHandler = cli.getXorHandler(); const vector<vector<TCLAP::Arg*>> xorArgGroups = xorHandler.getXorList(); for (const vector<TCLAP::Arg*>& xorArgGroup : xorArgGroups) { shortUsage += " {"; for (auto arg : xorArgGroup) shortUsage += arg->shortID() + "|"; shortUsage.pop_back(); shortUsage += '}'; } // Print regular arguments std::list<TCLAP::Arg*> argList = cli.getArgList(); for (auto arg : argList) { if (xorHandler.contains(arg)) continue; shortUsage += " " + arg->shortID(); } outStream << shortUsage << endl; }
virtual void usage(CmdLineInterface &c) { cout << "my usage message:" << endl; list < Arg * > args = c.getArgList(); for (ArgListIterator it = args.begin(); it != args.end(); it++) cout << (*it)->longID() << " (" << (*it)->getDescription() << ")" << endl; }
/** Specifies the command line parameters that list light curves and statistics * * @param[in,out] cmd The command-line parser used by the program * * @post @p cmd now contains command-line parameters for list input to * Lightcurve MC * * @exceptsafe Does not throw exceptions. */ void logSimLists(CmdLineInterface& cmd) { // Light curve list KeywordConstraint* lcAllowed = getLcList(); UnlabeledMultiArg<string>* argLcList = new UnlabeledMultiArg<string>("lclist", "List of light curves to model, in order. Allowed values are: " + lcAllowed->description(), true, lcAllowed); cmd.add(argLcList); // Statistics list KeywordConstraint* statAllowed = getStatList(); MultiArg<string>* argStatList = new MultiArg<string>("s", "stat", "List of statistics to calculate, in order. Allowed values are: " + statAllowed->description(), false, statAllowed); cmd.add(argStatList); }
inline MultiSwitchArg::MultiSwitchArg(const std::string& flag, const std::string& name, const std::string& desc, CmdLineInterface& parser, int init, Visitor* v ) : SwitchArg(flag, name, desc, false, v), _value( init ) { parser.add( this ); }
void NiceCmdLineOutput::failure(CmdLineInterface& cli, TCLAP::ArgException& e) { std::cerr << "Invalid command-line arguments. " << e.argId() << endl; std::cerr << e.error() << endl << endl; if (cli.hasHelpAndVersion()) { std::cerr << "Short usage:" << endl; printShortUsage(cli, std::cerr); std::cerr << endl << "For complete usage and help, type `" << getBinaryName() << " --help`" << endl << endl; } else { usage(cli); } }
UnlabeledValueArg<T>::UnlabeledValueArg(const std::string& name, const std::string& desc, bool req, T value, Constraint<T>* constraint, CmdLineInterface& parser, bool ignoreable, Visitor* v) : ValueArg<T>("", name, desc, req, value, constraint, v) { _ignoreable = ignoreable; OptionalUnlabeledTracker::check(req, toString()); parser.add( this ); }
void NiceCmdLineOutput::printLongUsage(CmdLineInterface& cli, std::ostream& outStream) const { TablePrinter tablePrinter(&outStream, { 20, 56 }); // Print XOR arguments TCLAP::XorHandler xorHandler = cli.getXorHandler(); const vector<vector<TCLAP::Arg*>> xorArgGroups = xorHandler.getXorList(); for (const vector<TCLAP::Arg*>& xorArgGroup : xorArgGroups) { for (auto arg : xorArgGroup) { if (arg != xorArgGroup[0]) outStream << "-- or --" << endl; tablePrinter.printRow({ arg->longID(), arg->getDescription() }); } outStream << endl; } // Print regular arguments std::list<TCLAP::Arg*> argList = cli.getArgList(); for (auto arg : argList) { if (xorHandler.contains(arg)) continue; tablePrinter.printRow({ arg->longID(), arg->getDescription() }); } }
/** Specifies the command line parameters that describe model parameter ranges * * @param[in,out] cmd The command-line parser used by the program * * @post @p cmd now contains the optional command-line parameters * for Lightcurve MC * * @exceptsafe Does not throw exceptions. */ void logModelParams(CmdLineInterface& cmd) { static PositiveNumber<Range> posRange; static UnitSubrange unitRange; ValueArg<Range>* argPer = new ValueArg<Range>("p", "period", "the smallest and largest periods, in days, to be tested. The period will be drawn from a log-uniform distribution.", false, Range(), &posRange); cmd.add(argPer); ValueArg<Range>* argAmp = new ValueArg<Range>("a", "amp", "the smallest and largest amplitudes to be tested. The amplitude will be drawn from a log-uniform distribution.", false, Range(), &posRange); cmd.add(argAmp); ValueArg<Range>* argPhi = new ValueArg<Range>("", "ph", "the smallest and largest initial phases to be tested. The phase will be drawn from a uniform distribution. MUST be a subinterval of [0.0, 1.0]. Set to \"0.0 1.0\" if unspecified.", false, Range(0.0, 1.0), &unitRange); cmd.add(argPhi); ValueArg<Range>* argDiffus = new ValueArg<Range>("d", "diffus", "the smallest and largest diffusion constants to be tested. The constant will be drawn from a log-uniform distribution.", false, Range(), &posRange); cmd.add(argDiffus); ValueArg<Range>* argWidth = new ValueArg<Range>("w", "width", "the smallest and largest event widths to be tested. The width will be drawn from a log-uniform distribution.", false, Range(), &posRange); cmd.add(argWidth); ValueArg<Range>* argWidth2 = new ValueArg<Range>("", "width2", "the smallest and largest secondary widths to be tested. The width will be drawn from a log-uniform distribution.", false, Range(), &posRange); cmd.add(argWidth2); ValueArg<Range>* argPer2 = new ValueArg<Range>("", "period2", "the smallest and largest secondary periods, in days, to be tested. The secondary period will be drawn from a log-uniform distribution.", false, Range(), &posRange); cmd.add(argPer2); ValueArg<Range>* argAmp2 = new ValueArg<Range>("", "amp2", "the smallest and largest secondary amplitudes to be tested. The secondary amplitude will be drawn from a log-uniform distribution.", false, Range(), &posRange); cmd.add(argAmp2); }
void NiceCmdLineOutput::version(CmdLineInterface& cli) { cout << endl << cli.getMessage() << " version " << cli.getVersion() << endl << endl; }