Esempio n. 1
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();
}
Esempio n. 2
0
int Kernel::innerRun(ProgramArgs& args)
{
    try
    {
        // do any user-level sanity checking
        validateSwitches(args);
    }
    catch (pdal_error e)
    {
        Utils::printError(e.what());
        outputHelp(args);
        return -1;
    }

    parseCommonOptions();
    return execute();
}
Esempio n. 3
0
bool StandardParser::parse(int argc, const char* argv[])
{
	if (Parser::parse(argc, argv))
		return true;

	if (help->boolValue())
	{
		// Provide help as requested
		outputHelp(cout);
		return true;
	}
	if (version->boolValue())
	{
		// Print the program version
		commandline::Help help(name(), m_version);
		help.outputVersion(cout);
		return true;
	}
	return false;
}
Esempio n. 4
0
bool NitfWrap::parseArgs(std::vector<std::string>& argList)
{
    ProgramArgs args;

    args.add("input,i", "Input filename", m_inputFile).setPositional();
    args.add("output,o", "Output filename",
        m_outputFile).setOptionalPositional();
    args.add("unwrap,u", "Unwrap NITF file", m_unwrap);
    try
    {
        m_nitfWriter.addArgs(args);
    }
    catch (arg_error& e)
    {
        throw error(e.m_error);
    }

    try
    {
        args.parse(argList);
    }
    catch (arg_error& e)
    {
        std::cerr << "nitfwrap: " << e.m_error << std::endl;
        outputHelp(args);
        return false;
    }

    if (!FileUtils::fileExists(m_inputFile))
    {
        std::ostringstream oss;

        oss << "Input file '" << m_inputFile << "' doesn't exist.";
        throw error(oss.str());
    }
    if (m_outputFile.empty())
        if (!m_unwrap)
            m_outputFile = FileUtils::stem(m_inputFile) + ".ntf";
    return true;
}
Esempio n. 5
0
// this just wraps ALL the code in total catch block
int Kernel::run(int argc, char const * argv[], const std::string& appName)
{
    m_appName = appName;

    ProgramArgs args;

    try
    {
        doSwitches(argc, argv, args);
    }
    catch (const pdal_error& e)
    {
        Utils::printError(e.what());
        return 1;
    }

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

    int startup_status = doStartup();
    if (startup_status)
        return startup_status;

    int execution_status = doExecution(args);

    // note we will try to shutdown cleanly even if we got an error condition
    // in the execution phase

    int shutdown_status = doShutdown();

    if (execution_status)
        return execution_status;

    return shutdown_status;
}