void CustomOptionDescription::checkIfPositional(const boost::program_options::positional_options_description& positionalDesc)
{
    for (size_t i = 0; i < positionalDesc.max_total_count(); ++i) {
        if (optionID == positionalDesc.name_for_position(i)) {
            boost::algorithm::erase_all(optionDisplayName, "-");
            isPositional = true;
            break;
        }
    }
}
void printHelp(const po::options_description& desc, const po::positional_options_description& posOpts) {
  std::vector<std::string> parts;
  parts.push_back("Usage: ntfs_linker");
  for (unsigned int i = 0; i < posOpts.max_total_count(); ++i) {
    parts.push_back(posOpts.name_for_position(i));
  }
  if (desc.options().size() > 0) {
    parts.push_back("[options]");
  }
  std::stringstream ss;
  std::copy(parts.begin(), parts.end(), std::ostream_iterator<std::string>(ss, " "));
  std::cout << "ntfs-linker, Copyright (c) Stroz Friedberg, LLC" << std::endl;
  std::cout << "Version " << VERSION << std::endl;
  std::cout << ss.str() << std::endl;
  std::cout << desc << std::endl;
}
	WolfwizardOptionStruct()
		:fopt("Options")
	{
		fopt.add_options()
			( "version,v", "print version" )
			( "help,h", "print help message" )
			( "config", po::value<std::string>(), "specify configuration file to load" )
			;
		popt.add( "cmd", 1);
	}
示例#4
0
void MeshData::setProgramOptions(boost::program_options::options_description &option_desc,
    boost::program_options::positional_options_description &option_pos)
{
  option_desc.add_options()
      ("block,b", po::value<std::string>(&blockName),"name of the data block to read from the SDF file")
      ("input,i", po::value<std::string>(&inputName),"name of the SDF file")
      ("cfd,d", "read data from old CFD files instead of SDF files");

  option_pos.add("block", 1);
  option_pos.add("input", 2);
}
示例#5
0
 /** process arguments according to option description */
 int run(int argc, char *argv[]) {
   po::options_description all_opts;
   all_opts.add(desc_).add(positional_);
   po::store(po::command_line_parser(argc, argv)
                 .options(all_opts)
                 .positional(positional_opts_)
                 .run(),
             vm_);
   po::notify(vm_);
   if (vm_.count("help")) {
     std::cout << cmd_name_ << " [options]";
     if (positional_opts_.max_total_count() != 0)
       std::cout << " " << positional_opts_.name_for_position(0);
     if (positional_opts_.max_total_count() > 1)
       std::cout << "...";
     std::cout << std::endl << desc_;
     return 0;
   }
   return process();
 }
示例#6
0
void options_cmd::get_description_cmd(po::options_description& desc, po::positional_options_description& pd)
{
    tara::api::options::get_description(desc, pd);
    desc.add_options()
    ("help,h", "produce help message")
    ("input,i", po::value(&input_file), "file to process")
    ("config,c", po::value<string>(), "a config file to parse")
    ("mode,o", po::value<string>()->default_value("seperate"), "selects the mode of operation (\"seperate\",\"as\",\"synthesis\",\"bugs\")")
    ("ofile,f", po::bool_switch(&output_to_file), "append the output to the end of the input file")
    ("metric", po::bool_switch(&output_metric), "outputs statistics about the run")
    ;
    pd.add("input", 1);
}
示例#7
0
// sets command line options
void set_options(opt::options_description &desc,
	opt::positional_options_description &po)
{
    desc.add_options()
        ("notes-file,n",
            opt::value<std::string>()->default_value(default_notes_filename()),
            "path of the notes file")
	("help,h", "show help message and exit")
        ("author,a", opt::value<std::string>()->default_value(get_user_name()),
                "author of the note")
        ("flags,f", opt::value<cnote_flag__>()->default_value(cnote_flag::Normal),
                "flags for the note")
        ("search,s", opt::value<std::string>(), "title of the note to search")
        ("db-file,d", opt::value<std::string>()
                ->default_value(std::string("/home/") + get_user_name() + "/.cndb"), 
                "name of file in which database will be stored")
        ("debug", opt::value<bool>()->default_value(false), "print the debug output")
        ("list,l", "list the notes");
    po.add("notes-file", -1);
}
示例#8
0
	void SetCommand::addPositionalOptions(boost::program_options::positional_options_description &positional_options)
	{
		positional_options.add("values", 1);
	}
示例#9
0
文件: main.cpp 项目: AmesianX/stp
void create_options()
{
    po::options_description hiddenOptions("Hidden options");
    hiddenOptions.add_options()
    ("file", po::value<string>(&infile)
        , "input file");

    ParserBM = bm;
    // Declare the supported options.
    po::options_description general_options("Most important options");
    general_options.add_options()
    ("help,h", "print this help")
    ("version", "print version number")
    ("disable-simplify", "disable all simplifications")
    ("switch-word,w", "switch off wordlevel solver")
    ("disable-opt-inc,a", "disable potentially size-increasing optimisations")
    ("disable-cbitp", "disable constant bit propagation")
    ("disable-equality", "disable equality propagation")
    ;

    po::options_description solver_options("SAT Solver options");
    solver_options.add_options()
    ("cryptominisat", "use cryptominisat2 as the solver")
    #ifdef USE_CRYPTOMINISAT4
    ("cryptominisat4", "use cryptominisat4 as the solver. Only use CryptoMiniSat 4.2 or above.")
    #endif
    ("simplifying-minisat", "use simplifying-minisat 2.2 as the solver")
    ("minisat", "use minisat 2.2 as the solver")
    ;

    po::options_description refinement_options("Refinement options");
    refinement_options.add_options()
    ("oldstyle-refinement", "Do abstraction-refinement outside the SAT solver")
    ("ackermanize,r" , po::bool_switch(&(bm->UserFlags.ackermannisation))
        , "eagerly encode array-read axioms (Ackermannistaion)")
    ("flatten,x", po::bool_switch(&(bm->UserFlags.xor_flatten_flag))
        , "flatten XORs")
    ;

    po::options_description print_options("Printing options");
    print_options.add_options()
    ("print-stpinput,b", po::bool_switch(&(bm->UserFlags.print_STPinput_back_flag))
        , "print STP input back to cout")
    ("print-back-CVC", po::bool_switch(&(bm->UserFlags.print_STPinput_back_CVC_flag))
        , "print input in CVC format, then exit")
    ("print-back-SMTLIB2", po::bool_switch(&(bm->UserFlags.print_STPinput_back_SMTLIB2_flag))
        , "print input in SMT-LIB2 format, then exit")
    ("print-back-SMTLIB1", po::bool_switch((&bm->UserFlags.print_STPinput_back_SMTLIB1_flag))
        , "print input in SMT-LIB1 format, then exit")
    ("print-back-GDL", po::bool_switch(&(bm->UserFlags.print_STPinput_back_GDL_flag))
        , "print AiSee's graph format, then exit")
    ("print-back-dot", po::bool_switch(&(bm->UserFlags.print_STPinput_back_dot_flag))
        , "print dotty/neato's graph format, then exit")
    ("print-counterex,p", po::bool_switch(&(bm->UserFlags.print_counterexample_flag))
        , "print counterexample")
    ("print-counterexbin,y", po::bool_switch(&(bm->UserFlags.print_binary_flag))
        , "print counterexample in binary")
    ("print-arrayval,q", po::bool_switch(&(bm->UserFlags.print_arrayval_declaredorder_flag))
        , "print arrayval declared order")
    ("print-functionstat,s", po::bool_switch(&(bm->UserFlags.stats_flag))
        , "print function statistics")
    ("print-quickstat,t", po::bool_switch(&(bm->UserFlags.quick_statistics_flag))
        , "print quick statistics")
    ("print-nodes,v", po::bool_switch(&(bm->UserFlags.print_nodes_flag))
        , "print nodes ")
    /*("constr-counterex,c", po::bool_switch(&(bm->UserFlags.construct_counterexample_flag))
        , "construct counterexample")*/
    ("print-varorder,z", po::bool_switch(&(bm->UserFlags.print_sat_varorder_flag))
        , "Print SAT variable order")
    ("print-output,n", po::bool_switch(&(bm->UserFlags.print_output_flag))
        , "Print output")
    ;

    po::options_description input_options("Input options");
    input_options.add_options()
    ("SMTLIB1,m", "use the SMT-LIB1 format parser")
    ("SMTLIB2", "use the SMT-LIB2 format parser")
    ;

    po::options_description output_options("Output options");
    output_options.add_options()
    ("output-CNF", po::bool_switch(&(bm->UserFlags.output_CNF_flag))
        , "save the CNF into output_[0..n].cnf")
    ("output-bench", po::bool_switch(&(bm->UserFlags.output_bench_flag))
        , "save in ABC's bench format to output.bench")
    ;

    po::options_description misc_options("Output options");
    misc_options.add_options()
    ("exit-after-CNF", po::bool_switch(&(bm->UserFlags.exit_after_CNF))
        , "exit after the CNF has been generated")
    #ifndef _MSC_VER
    ("timeout,g", po::value<size_t>(&hardTimeout)
        , "timeout (seconds until STP gives up)")
    #endif
    ("seed,i", po::value<size_t>(&random_seed)
        , "set random seed for STP's satisfiable output. Random_seed is an integer >= 0")
    ("random-seed"
        , "generate a random number for the SAT solver.")
    ("check-sanity,d"
        , "construct counterexample and check it")
    ;

    cmdline_options
    .add(general_options)
    .add(solver_options)
    .add(refinement_options)
    .add(print_options)
    .add(input_options)
    .add(output_options)
    .add(misc_options)
    .add(hiddenOptions)
    ;

    //Register everything except hiddenOptions
    visible_options
    .add(general_options)
    .add(solver_options)
    .add(refinement_options)
    .add(print_options)
    .add(input_options)
    .add(output_options)
    .add(misc_options)
    ;

    pos_options.add("file", 1);
}
示例#10
0
void SpinReader::addOptions(boost::program_options::positional_options_description& pos_opts_desc)
{
  pos_opts_desc.add("logs", -1);
}
示例#11
0
int main( int argc, char* argv[] )
{
	unsigned	days;
	std::string	saltStr;
	std::string	b64SaltStr;

	PO::options_description desc( "Usage:\n"
				      "  wolfpasswd -D passwordfile username\n"
				      "  wolfpasswd [-c] [-d days] passwordfile username [user info]\n"
				      "  wolfpasswd -b[c] [-d days] passwordfile username password [user info]\n"
				      "  wolfpasswd -n [-s/-S salt] [-d days] username [user info]\n"
				      "  wolfpasswd -nb [-s/-S salt] [-d days] username password [user info]\n"
				      "  wolfpasswd -h\n"
				      "Options" );
	desc.add_options()
			( "help,h", "Display this help message." )
			( "create,c", "Create the file if it doesn't exist." )
			( "salt,s", PO::value< std::string >( &saltStr ), "Use the specified plain text salt (only valid with --display-only)." )
			( "base64-salt,S", PO::value< std::string >( &b64SaltStr ), "Use the specified base64 salt (only valid with --display-only)." )
			( "days,d", PO::value< unsigned >( &days )->default_value( 0 ), "Set the password expiration after <days>." )
			( "display-only,n", "Don't update the password file; display results on stdout." )
			( "batch,b", "Use the password from the command line instead of prompting for it.")
			( "delete,D", "Delete the specified user." )
			;

	PO::options_description cmdArgs( "Arguments" );
	cmdArgs.add_options()
			( "posArgs", PO::value< std::vector<std::string> >(), "positional arguments" )
			;
	cmdArgs.add( desc );

	PO::positional_options_description posArgs;
	posArgs.add( "posArgs", -1 );

	PO::variables_map vm;
	try	{
		PO::store( PO::command_line_parser( argc, argv ).
			   options( cmdArgs ).positional( posArgs ).run(), vm );
		PO::notify( vm );
	}
	catch( std::exception& e )	{
		std::cerr << "\nERROR: " << e.what() << "\n\n";
		std::cout << desc << "\n";
		return 2;
	}

	bool	createFile = false;
	bool	displayOnly = false;
	bool	batchPwd = false;
	bool	delUser = false;

	if ( vm.count( "create" ))
		createFile = true;
	if ( vm.count( "display-only" ))
		displayOnly = true;
	if ( vm.count( "batch" ))
		batchPwd = true;
	if ( vm.count( "delete" ))
		delUser = true;

	// deal with help
	if ( vm.count( "help" ))	{
		if ( createFile || displayOnly|| batchPwd || delUser
				|| vm.count( "posArgs" ))
			std::cout << "\nWARNING: --help ignores all other flags and arguments.\n\n";
		std::cout << desc << "\n";
		return 1;
	}

	if ( !vm.count( "posArgs" ))	{
		std::cerr << "\nERROR: no arguments given.\n\n";
		std::cout << desc << "\n";
		return 2;
	}
	const std::vector<std::string>& args = vm["posArgs"].as< std::vector<std::string> >();

	_Wolframe::system::RandomGeneratorImpl rnd;

	// display only
	if ( displayOnly )	{
		bool	wrong = false;
		if ( createFile )	{
			std::cerr << "\nERROR: --create cannot be used with --display-only.";
			wrong = true;
		}
		if ( delUser )	{
			std::cerr << "\nERROR: --delete cannot be used with --display-only.";
			wrong = true;
		}
		if ( batchPwd )	{
			if ( args.size() < 2 )	{
				std::cerr << "\nERROR: too few arguments.";
				wrong = true;
			}
			else if ( args.size() > 3 )	{
				std::cerr << "\nERROR: too many arguments.";
				wrong = true;
			}
		}
		else	{
			if ( args.size() > 2 )	{
				std::cerr << "\nERROR: too many arguments.";
				wrong = true;
			}
		}
		if ( !saltStr.empty() && !b64SaltStr.empty() )	{
			std::cerr << "\nERROR: both --salt and --base64-salt arguments given.";
			wrong = true;
		}
		if ( wrong )	{
			std::cout << "\n\n" << desc << "\n";
			return 2;
		}

		// All parameters are OK
		std::string passwd;
		WA::PwdFileUser user;
		if ( ! batchPwd )	{
			passwd = WA::getPassword();
			if( args.size() == 2 )
				user.info = args[1];
		}
		else	{
			passwd = args[1];
			if( args.size() == 3 )
				user.info = args[2];
		}
		// now do the job
		WA::PasswordHash::Salt salt;
		if ( saltStr.empty() && b64SaltStr.empty() )
			salt = WA::PasswordHash::Salt( rnd );
		else	{
			if ( !saltStr.empty() )
				b64SaltStr = _Wolframe::base64::encode( saltStr.data(), saltStr.size(), 0 );
			salt = WA::PasswordHash::Salt( b64SaltStr );
		}
		WA::PasswordHash pwd( salt, passwd );

		user.user = args[0];
		user.hash = pwd.toString();
		user.expiry = 0;
		std::cout << "Password line: " << WA::PasswordFile::passwdLine( user );
	}
	// delete user
	else if ( delUser )	{
		bool	wrong = false;
		if ( createFile )	{
			std::cerr << "\nERROR: --create cannot be used with --delete.";
			wrong = true;
		}
		if ( args.size() < 2 )	{
			std::cerr << "\nERROR: too few arguments.";
			wrong = true;
		}
		else if ( args.size() > 2 )	{
			std::cerr << "\nERROR: too many arguments.";
			wrong = true;
		}
		if ( wrong )	{
			std::cout << "\n\n" << desc << "\n";
			return 2;
		}
		if ( ! saltStr.empty() )
			std::cerr << "\nWarning: --salt argument ignored.";
		if ( ! b64SaltStr.empty() )
			std::cerr << "\nWarning: --base64-salt argument ignored.";

		// All parameters are OK
		try	{
			std::string filename = WU::resolvePath( boost::filesystem::absolute( args[0] ).string());
			WA::PasswordFile pwdFile( filename );

			if ( pwdFile.delUser( args[1] ))
				std::cout << "User '" << args[1] << "' removed from password file '"
					  << filename << "'.";
			else
				std::cout << "User '" << args[1] << "' not found in password file '"
					  << filename << "'.";
		}
		catch( std::exception& e )	{
			std::cerr << "Error removing user '" << args[1] << "': " << e.what() << "\n\n";
			return 1;
		}
	}
	// normal operation
	else	{
		bool	wrong = false;
		if ( batchPwd )	{
			if ( args.size() < 3 )	{
				std::cerr << "\nERROR: too few arguments.";
				wrong = true;
			}
			else if ( args.size() > 4 )	{
				std::cerr << "\nERROR: too many arguments.";
				wrong = true;
			}
		}
		else	{
			if ( args.size() < 2 )	{
				std::cerr << "\nERROR: too few arguments.";
				wrong = true;
			}
			if ( args.size() > 3 )	{
				std::cerr << "\nERROR: too many arguments.";
				wrong = true;
			}
		}
		if ( !saltStr.empty() && !b64SaltStr.empty() )	{
			std::cerr << "\nERROR: both --salt and --base64-salt arguments given.";
			wrong = true;
		}

		if ( wrong )	{
			std::cout << "\n\n" << desc << "\n";
			return 2;
		}

		// Al parameters are OK, do the job
		bool create = false;
		if ( createFile )
			create = true;
		try	{
			std::string filename = WU::resolvePath( boost::filesystem::absolute( args[0] ).string());
			WA::PasswordFile pwdFile( filename, create );
			WA::PwdFileUser user;

			std::string passwd;
			if ( ! batchPwd )	{
				passwd = WA::getPassword();
				if( args.size() == 3 )
					user.info = args[2];
			}
			else	{
				passwd = args[2];
				if( args.size() == 4 )
					user.info = args[3];
			}
			WA::PasswordHash::Salt salt;
			if ( saltStr.empty() && b64SaltStr.empty() )
				salt = WA::PasswordHash::Salt( rnd );
			else	{
				if ( !saltStr.empty() )
					b64SaltStr = _Wolframe::base64::encode( saltStr.data(), saltStr.size(), 0 );
				salt = WA::PasswordHash::Salt( b64SaltStr );
			}
			WA::PasswordHash pwd( salt, passwd );
			user.user = args[1];
			user.hash = pwd.toString();
			user.expiry = 0;
			if ( pwdFile.addUser( user ) )
				std::cout << "User '" << args[1] << "' added to the password file '"
					  << filename << "'.";
			else
				std::cout << "Error: user '" << args[1] << "' already exists in the password file '"
					  << filename << "'.";

		}
		catch( std::exception& e )	{
			std::cerr << "Error adding user '" << args[1] << "': " << e.what() << "\n\n";
			return 1;
		}
	}
	std::cout << "\nDone.\n\n";
	return 0;
}
 void addPositional(boost::program_options::options_description& desc,
                    boost::program_options::positional_options_description& positional) override {
   namespace po = boost::program_options;
   desc.add_options()("crf", po::value<std::string>(&r_response), "Calibration file with radiometric response");
   positional.add("crf", 1);
 }
示例#13
0
void message::init_positional_options_description(po::positional_options_description &pos_desc)
{
    pos_desc.add("input-file", -1);
}
示例#14
0
 //! add a positional argument
 void add_positional(const std::string& str) {
   pos_opts.add(str.c_str(), 1);
 }
示例#15
0
 void addPositional(po::positional_options_description& opts) {
   opts.add("donor", 1);
   opts.add("model", 1);
   opts.add("trajs", -1);
 }