Ejemplo n.º 1
0
std::ostream& Configuration::outputHelp(std::ostream& out) const {
	out << "---------------------------------------------------------------------------------------"<< std::endl;
	outputVersion(out) 
		<< "---------------------------------------------------------------------------------------"<< std::endl
		<< "Usage: " ;
		if (binaryName()) out << *binaryName();
		else out << "<binary>";
		out << " [<OPTIONS>] [<CONSTANTS>] <INPUT_FILES>" 											<< std::endl
		<< "---------------------------------------------------------------------------------------"<< std::endl
		<< "OPTIONS:"																				<< std::endl;
	outputOptions(out);
	out 																							<< std::endl
		<< "CONSTANTS:"																				<< std::endl
		<< "     <identifier>=<value>"																<< std::endl
		<< "          - Defines <identifier> to be a macro which expands to <value>"				<< std::endl;
	return out;
}
Ejemplo n.º 2
0
void Kernel::outputHelp()
{
    outputVersion();


    for (auto iter = m_options.begin(); iter != m_options.end(); ++iter)
    {
        const po::options_description* options = *iter;
        std::cout << *options;
        std::cout << std::endl;
    }

    std::string headline("------------------------------------------------------------------------------------------");

    std::cout <<"\nFor more information, see the full documentation for PDAL at:\n";

    std::cout << "  http://pdal.io/\n";
    std::cout << headline << std::endl;
    std::cout << std::endl;

    return;
}
Ejemplo n.º 3
0
int Kernel::innerRun()
{
    // handle the well-known options
    if (m_showVersion)
    {
        outputVersion();
        return 0;
    }

    if (m_showHelp)
    {
        outputHelp();
        return 0;
    }

    if (!m_showOptions.empty())
    {
        pdal::StageFactory factory;
        std::cout << factory.toRST(m_showOptions) << std::endl;
        return 0;
    }
    try
    {
        // do any user-level sanity checking
        validateSwitches();
        collectExtraOptions();
    }
    catch (app_usage_error e)
    {
        std::string s("Usage error: ");
        printError(s + e.what());
        outputHelp();
        return 1;
    }

    return execute();
}
Ejemplo n.º 4
0
int main(int argc, char* argv[])
{
    po::options_description options;
    po::positional_options_description positional;
    po::variables_map variables;
    positional.add("action", 1);

    options.add_options()
        ("action", po::value<std::string>(), "action name")
        ("version", po::value<bool>()->zero_tokens()->implicit_value(true), "Show version info")
        ("help,h", po::value<bool>()->zero_tokens()->implicit_value(true), "Print help message")
            ;
        
    if (argc < 2)
    {
        std::cerr << "Action not specified!" << std::endl << std::endl;
        outputVersion(); return 1;
    }

    try
    {
        po::store(po::command_line_parser(2, argv).
            options(options).positional(positional).run(), 
            variables);
    }
    catch (boost::program_options::unknown_option& e)
    {
#if BOOST_VERSION >= 104200

        std::cerr << "Unknown option '" << e.get_option_name() <<"' not recognized" << std::endl << std::endl;
#else
        std::cerr << "Unknown option '" << std::string(e.what()) <<"' not recognized" << std::endl << std::endl;
#endif
        outputVersion();
        return 1;

    }

    int count(argc - 1); // remove the 1st argument
    const char** args = const_cast<const char**>(&argv[1]);
    
    
    if (variables.count("version") || variables.count("help") || !variables.count("action"))
    {
        outputVersion();
        return 0;
    }

    std::string action = variables["action"].as<std::string>();

    if (boost::iequals(action, "translate"))
    {
        pdal::kernel::Translate app(count, args);
        return app.run();
    }

    if (boost::iequals(action, "info"))
    {
        pdal::kernel::Info app(count, args);
        return app.run();
    }

    if (boost::iequals(action, "pipeline"))
    {
        pdal::kernel::Pipeline app(count, args);
        return app.run();
    }

    if (boost::iequals(action, "query"))
    {
        pdal::kernel::Query app(count, args);
        return app.run();
    }
    
    std::cerr << "Action '" << action <<"' not recognized" << std::endl << std::endl;
    outputVersion();
    return 1;
}