111be35a1SLionel Sambuc // Copyright 2011 Google Inc. 211be35a1SLionel Sambuc // All rights reserved. 311be35a1SLionel Sambuc // 411be35a1SLionel Sambuc // Redistribution and use in source and binary forms, with or without 511be35a1SLionel Sambuc // modification, are permitted provided that the following conditions are 611be35a1SLionel Sambuc // met: 711be35a1SLionel Sambuc // 811be35a1SLionel Sambuc // * Redistributions of source code must retain the above copyright 911be35a1SLionel Sambuc // notice, this list of conditions and the following disclaimer. 1011be35a1SLionel Sambuc // * Redistributions in binary form must reproduce the above copyright 1111be35a1SLionel Sambuc // notice, this list of conditions and the following disclaimer in the 1211be35a1SLionel Sambuc // documentation and/or other materials provided with the distribution. 1311be35a1SLionel Sambuc // * Neither the name of Google Inc. nor the names of its contributors 1411be35a1SLionel Sambuc // may be used to endorse or promote products derived from this software 1511be35a1SLionel Sambuc // without specific prior written permission. 1611be35a1SLionel Sambuc // 1711be35a1SLionel Sambuc // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1811be35a1SLionel Sambuc // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1911be35a1SLionel Sambuc // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2011be35a1SLionel Sambuc // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2111be35a1SLionel Sambuc // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2211be35a1SLionel Sambuc // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2311be35a1SLionel Sambuc // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2411be35a1SLionel Sambuc // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2511be35a1SLionel Sambuc // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2611be35a1SLionel Sambuc // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2711be35a1SLionel Sambuc // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2811be35a1SLionel Sambuc 2911be35a1SLionel Sambuc /// \file cli/common.hpp 3011be35a1SLionel Sambuc /// Utility functions to implement CLI subcommands. 3111be35a1SLionel Sambuc 3211be35a1SLionel Sambuc #if !defined(CLI_COMMON_HPP) 3311be35a1SLionel Sambuc #define CLI_COMMON_HPP 3411be35a1SLionel Sambuc 3511be35a1SLionel Sambuc #include <memory> 3611be35a1SLionel Sambuc #include <set> 37*84d9c625SLionel Sambuc #include <vector> 3811be35a1SLionel Sambuc 39*84d9c625SLionel Sambuc #include "engine/test_result.hpp" 4011be35a1SLionel Sambuc #include "utils/cmdline/base_command.hpp" 4111be35a1SLionel Sambuc #include "utils/cmdline/options.hpp" 4211be35a1SLionel Sambuc #include "utils/cmdline/parser.hpp" 4311be35a1SLionel Sambuc #include "utils/cmdline/ui.hpp" 4411be35a1SLionel Sambuc #include "utils/config/tree.hpp" 4511be35a1SLionel Sambuc #include "utils/datetime.hpp" 4611be35a1SLionel Sambuc #include "utils/fs/path.hpp" 4711be35a1SLionel Sambuc #include "utils/optional.hpp" 4811be35a1SLionel Sambuc 4911be35a1SLionel Sambuc namespace utils { 5011be35a1SLionel Sambuc namespace fs { 5111be35a1SLionel Sambuc class path; 5211be35a1SLionel Sambuc } // namespace fs 5311be35a1SLionel Sambuc } // namespace utils 5411be35a1SLionel Sambuc 5511be35a1SLionel Sambuc namespace engine { 5611be35a1SLionel Sambuc class test_case; 57*84d9c625SLionel Sambuc class test_filter; 5811be35a1SLionel Sambuc } // namespace engine 5911be35a1SLionel Sambuc 6011be35a1SLionel Sambuc namespace cli { 6111be35a1SLionel Sambuc 6211be35a1SLionel Sambuc 6311be35a1SLionel Sambuc extern const utils::cmdline::path_option build_root_option; 6411be35a1SLionel Sambuc extern const utils::cmdline::path_option kyuafile_option; 65*84d9c625SLionel Sambuc extern const utils::cmdline::list_option results_filter_option; 6611be35a1SLionel Sambuc extern const utils::cmdline::path_option store_option; 6711be35a1SLionel Sambuc extern const utils::cmdline::property_option variable_option; 6811be35a1SLionel Sambuc 6911be35a1SLionel Sambuc 7011be35a1SLionel Sambuc /// Base type for commands defined in the cli module. 7111be35a1SLionel Sambuc /// 7211be35a1SLionel Sambuc /// All commands in Kyua receive a configuration object as their runtime 7311be35a1SLionel Sambuc /// data parameter because the configuration file applies to all the 7411be35a1SLionel Sambuc /// commands. 7511be35a1SLionel Sambuc typedef utils::cmdline::base_command< utils::config::tree > cli_command; 7611be35a1SLionel Sambuc 7711be35a1SLionel Sambuc 7811be35a1SLionel Sambuc /// Scoped, strictly owned pointer to a cli_command. 7911be35a1SLionel Sambuc typedef std::auto_ptr< cli_command > cli_command_ptr; 8011be35a1SLionel Sambuc 8111be35a1SLionel Sambuc 82*84d9c625SLionel Sambuc /// Collection of result types. 83*84d9c625SLionel Sambuc /// 84*84d9c625SLionel Sambuc /// This is a vector rather than a set because we want to respect the order in 85*84d9c625SLionel Sambuc /// which the user provided the types. 86*84d9c625SLionel Sambuc typedef std::vector< engine::test_result::result_type > result_types; 87*84d9c625SLionel Sambuc 88*84d9c625SLionel Sambuc 8911be35a1SLionel Sambuc utils::optional< utils::fs::path > get_home(void); 9011be35a1SLionel Sambuc 9111be35a1SLionel Sambuc utils::optional< utils::fs::path > build_root_path( 9211be35a1SLionel Sambuc const utils::cmdline::parsed_cmdline&); 9311be35a1SLionel Sambuc utils::fs::path kyuafile_path(const utils::cmdline::parsed_cmdline&); 94*84d9c625SLionel Sambuc result_types get_result_types(const utils::cmdline::parsed_cmdline&); 9511be35a1SLionel Sambuc utils::fs::path store_path(const utils::cmdline::parsed_cmdline&); 9611be35a1SLionel Sambuc 9711be35a1SLionel Sambuc std::set< engine::test_filter > parse_filters( 9811be35a1SLionel Sambuc const utils::cmdline::args_vector&); 9911be35a1SLionel Sambuc bool report_unused_filters(const std::set< engine::test_filter >&, 10011be35a1SLionel Sambuc utils::cmdline::ui*); 10111be35a1SLionel Sambuc 10211be35a1SLionel Sambuc std::string format_delta(const utils::datetime::delta&); 10311be35a1SLionel Sambuc std::string format_result(const engine::test_result&); 10411be35a1SLionel Sambuc std::string format_test_case_id(const engine::test_case&); 10511be35a1SLionel Sambuc std::string format_test_case_id(const engine::test_filter&); 10611be35a1SLionel Sambuc 10711be35a1SLionel Sambuc 10811be35a1SLionel Sambuc } // namespace cli 10911be35a1SLionel Sambuc 11011be35a1SLionel Sambuc #endif // !defined(CLI_COMMON_HPP) 111