コード例 #1
0
ファイル: cmd_config.cpp プロジェクト: jmmv/kyua
/// 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
ファイル: cmd_report.cpp プロジェクト: racktopsystems/kyua
/// 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
ファイル: cmd_db_exec.cpp プロジェクト: Bhudipta/minix
/// 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;
    }
}
コード例 #4
0
ファイル: cmd_report_html.cpp プロジェクト: namore/kyua
/// Entry point for the "report-html" 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
cli::cmd_report_html::run(cmdline::ui* ui,
                          const cmdline::parsed_cmdline& cmdline,
                          const config::tree& UTILS_UNUSED_PARAM(user_config))
{
    const result_types types = get_result_types(cmdline);

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

    const fs::path directory =
        cmdline.get_option< cmdline::path_option >("output");
    create_top_directory(directory, cmdline.has_option("force"));
    html_hooks hooks(ui, directory, types);
    drivers::scan_results::drive(results_file,
                                 std::set< engine::test_filter >(),
                                 hooks);
    hooks.write_summary();

    return EXIT_SUCCESS;
}