/* This file is part of epubgrep. * Copyright © 2021 tastytea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ #ifndef EPUBGREP_OPTIONS_HPP #define EPUBGREP_OPTIONS_HPP #include "fs-compat.hpp" #include #include #include #include #include #include namespace epubgrep::options { namespace po = boost::program_options; enum class regex_kind { basic, extended, perl }; struct options { bool help{false}; bool version{false}; regex_kind regex{regex_kind::basic}; bool grep{false}; bool ignore_case{false}; std::vector regexp; bool raw{false}; std::uint64_t context{0}; bool nocolor{false}; bool no_fn_fs{false}; bool no_fn_epub{false}; bool recursive{false}; bool dereference_recursive{false}; std::vector input_file; bool ignore_archive_errors{false}; bool debug{false}; bool json{false}; bool html{false}; //! For the debug output. friend std::ostream &operator<<(std::ostream &out, const options &opts); }; //! Parse options and return them. [[nodiscard]] options parse_options(int argc, char *argv[]); /*! * @brief Returns the path of the config file. * * If XDG_CONFIG_HOME is set: ${XDG_CONFIG_HOME}/epubgrep.conf * If HOME is set: ${HOME}/.config/epubgrep.conf * Otherwise: epubgrep.conf */ [[nodiscard]] fs::path get_config_path(); //! Parse variables map and return nice options struct. [[nodiscard]] options parse_again(const po::variables_map &vm); } // namespace epubgrep::options #endif // EPUBGREP_OPTIONS_HPP