// Copyright 2010 The Kyua Authors.1// All rights reserved.2//3// Redistribution and use in source and binary forms, with or without4// modification, are permitted provided that the following conditions are5// met:6//7// * Redistributions of source code must retain the above copyright8// notice, this list of conditions and the following disclaimer.9// * Redistributions in binary form must reproduce the above copyright10// notice, this list of conditions and the following disclaimer in the11// documentation and/or other materials provided with the distribution.12// * Neither the name of Google Inc. nor the names of its contributors13// may be used to endorse or promote products derived from this software14// without specific prior written permission.15//16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2728/// \file utils/cmdline/ui.hpp29/// Abstractions and utilities to write formatted messages to the console.3031#if !defined(UTILS_CMDLINE_UI_HPP)32#define UTILS_CMDLINE_UI_HPP3334#include "utils/cmdline/ui_fwd.hpp"3536#include <cstddef>37#include <string>3839#include "utils/optional_fwd.hpp"40#include "utils/text/table_fwd.hpp"4142namespace utils {43namespace cmdline {444546/// Interface to interact with the CLI.47///48/// The main purpose of this class is to substitute direct usages of stdout and49/// stderr. An instance of this class is passed to every command of a CLI,50/// which allows unit testing and validation of the interaction with the user.51///52/// This class writes directly to stdout and stderr. For testing purposes, see53/// the utils::cmdline::ui_mock class.54class ui {55public:56virtual ~ui(void);5758virtual void err(const std::string&, const bool = true);59virtual void out(const std::string&, const bool = true);60virtual optional< std::size_t > screen_width(void) const;6162void out_wrap(const std::string&);63void out_tag_wrap(const std::string&, const std::string&,64const bool = true);65void out_table(const utils::text::table&, utils::text::table_formatter,66const std::string&);67};686970void print_error(ui*, const std::string&);71void print_info(ui*, const std::string&);72void print_warning(ui*, const std::string&);737475} // namespace cmdline76} // namespace utils7778#endif // !defined(UTILS_CMDLINE_UI_HPP)798081