Пример #1
0
/// Entry point for the "config" subcommand.
///
/// \param ui Object to interact with the I/O of the program.
/// \param cmdline Representation of the command line to the subcommand.
/// \param user_config The runtime configuration of the program.
///
/// \return 0 if everything is OK, 1 if any of the necessary documents cannot be
/// opened.
int
cmd_config::run(cmdline::ui* ui, const cmdline::parsed_cmdline& cmdline,
               const config::tree& user_config)
{
    const config::properties_map properties = user_config.all_properties();
    if (cmdline.arguments().empty())
        return print_all(ui, properties);
    else
        return print_some(ui, properties, cmdline.arguments());
}
Пример #2
0
/// Entry point for the "report" subcommand.
///
/// \param ui Object to interact with the I/O of the program.
/// \param cmdline Representation of the command line to the subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return 0 if everything is OK, 1 if the statement is invalid or if there is
/// any other problem.
int
cmd_report::run(cmdline::ui* ui,
                const cmdline::parsed_cmdline& cmdline,
                const config::tree& UTILS_UNUSED_PARAM(user_config))
{
    std::auto_ptr< std::ostream > output = utils::open_ostream(
        cmdline.get_option< cmdline::path_option >("output"));

    const fs::path results_file = layout::find_results(
        results_file_open(cmdline));

    const result_types types = get_result_types(cmdline);
    report_console_hooks hooks(*output.get(), cmdline.has_option("verbose"),
                               types, results_file);
    const drivers::scan_results::result result = drivers::scan_results::drive(
        results_file, parse_filters(cmdline.arguments()), hooks);

    return report_unused_filters(result.unused_filters, ui) ?
        EXIT_FAILURE : EXIT_SUCCESS;
}
Пример #3
0
/// Entry point for the "db-exec" subcommand.
///
/// \param ui Object to interact with the I/O of the program.
/// \param cmdline Representation of the command line to the subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return 0 if everything is OK, 1 if the statement is invalid or if there is
/// any other problem.
int
cmd_db_exec::run(cmdline::ui* ui, const cmdline::parsed_cmdline& cmdline,
                 const config::tree& UTILS_UNUSED_PARAM(user_config))
{
    try {
        store::backend backend = store::backend::open_rw(
            cli::store_path(cmdline));
        sqlite::statement stmt = backend.database().create_statement(
            flatten_args(cmdline.arguments()));

        if (stmt.step()) {
            if (!cmdline.has_option("no-headers"))
                ui->out(cli::format_headers(stmt));
            do
                ui->out(cli::format_row(stmt));
            while (stmt.step());
        }

        return EXIT_SUCCESS;
    } catch (const sqlite::error& e) {
        cmdline::print_error(ui, F("SQLite error: %s") % e.what());
        return EXIT_FAILURE;
    }
}