2021-05-20 04:30:31 +02:00
|
|
|
/* This file is part of epubgrep.
|
|
|
|
* Copyright © 2021 tastytea <tastytea@tastytea.de>
|
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EPUBGREP_OPTIONS_HPP
|
|
|
|
#define EPUBGREP_OPTIONS_HPP
|
|
|
|
|
2021-05-20 10:30:36 +02:00
|
|
|
#include "fs-compat.hpp"
|
2021-05-20 04:30:31 +02:00
|
|
|
|
2021-05-20 10:30:36 +02:00
|
|
|
#include <boost/program_options/variables_map.hpp>
|
2021-05-20 09:05:39 +02:00
|
|
|
|
2021-05-27 17:20:00 +02:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
2021-06-01 15:25:39 +02:00
|
|
|
#include <ostream>
|
2021-05-27 17:20:00 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2021-05-21 01:50:13 +02:00
|
|
|
namespace epubgrep::options
|
2021-05-20 04:30:31 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
namespace po = boost::program_options;
|
|
|
|
|
2021-05-27 17:20:00 +02:00
|
|
|
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<std::string> 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<std::string> input_file;
|
2021-05-27 21:48:35 +02:00
|
|
|
bool ignore_archive_errors{false};
|
2021-06-01 13:41:54 +02:00
|
|
|
bool debug{false};
|
2021-06-01 19:17:44 +02:00
|
|
|
bool json{false};
|
2021-06-01 15:25:39 +02:00
|
|
|
|
|
|
|
//! For the debug output.
|
|
|
|
friend std::ostream &operator<<(std::ostream &out, const options &opts);
|
2021-05-27 17:20:00 +02:00
|
|
|
};
|
|
|
|
|
2021-05-20 04:30:31 +02:00
|
|
|
//! Parse options and return them.
|
2021-05-27 17:20:00 +02:00
|
|
|
[[nodiscard]] options parse_options(int argc, char *argv[]);
|
2021-05-20 04:30:31 +02:00
|
|
|
|
2021-05-20 09:05:39 +02:00
|
|
|
/*!
|
|
|
|
* @brief Returns the path of the config file.
|
|
|
|
*
|
2021-05-20 10:03:09 +02:00
|
|
|
* If XDG_CONFIG_HOME is set: ${XDG_CONFIG_HOME}/epubgrep.conf
|
|
|
|
* If HOME is set: ${HOME}/.config/epubgrep.conf
|
|
|
|
* Otherwise: epubgrep.conf
|
2021-05-20 09:05:39 +02:00
|
|
|
*/
|
2021-05-24 13:00:03 +02:00
|
|
|
[[nodiscard]] fs::path get_config_path();
|
2021-05-20 09:05:39 +02:00
|
|
|
|
2021-05-27 17:20:00 +02:00
|
|
|
//! Parse variables map and return nice options struct.
|
|
|
|
[[nodiscard]] options parse_again(const po::variables_map &vm);
|
|
|
|
|
2021-05-21 01:50:13 +02:00
|
|
|
} // namespace epubgrep::options
|
2021-05-20 04:30:31 +02:00
|
|
|
|
|
|
|
#endif // EPUBGREP_OPTIONS_HPP
|