summaryrefslogtreecommitdiff
path: root/include/cliargsparser.h
blob: c16d44c2458462e30e38f808277cfa275efd7b12 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef NEWSBOAT_CLIARGSPARSER_H_
#define NEWSBOAT_CLIARGSPARSER_H_

#include "libnewsboat-ffi/src/cliargsparser.rs.h"

#include <string>
#include <vector>

#include "3rd-party/optional.hpp"

#include "logger.h"

namespace newsboat {
class CliArgsParser {
public:
	CliArgsParser(int argc, char* argv[]);
	~CliArgsParser() = default;

	bool do_import() const;

	bool do_export() const;

	bool do_vacuum() const;

	bool do_cleanup() const;

	std::string importfile() const;

	/// If non-null, Newsboat should import read articles info from this
	/// filepath.
	nonstd::optional<std::string> readinfo_import_file() const;

	/// If non-null, Newsboat should export read articles info to this
	/// filepath.
	nonstd::optional<std::string> readinfo_export_file() const;

	std::string program_name() const;

	unsigned int show_version() const;

	bool silent() const;

	bool using_nonstandard_configs() const;

	/// If non-null, the creator of `CliArgsParser` object should call `exit()`
	/// with this code.
	nonstd::optional<int> return_code() const;

	/// If `display_msg()` is not empty, the creator of `CliArgsParser` should
	/// print its contents to stderr.
	///
	/// \note The contents of this string should be checked before processing
	/// `return_code()`.
	std::string display_msg() const;

	/// If `should_print_usage()` is `true`, the creator of `CliArgsParser`
	/// object should print usage information.
	///
	/// \note This field should be checked before processing
	/// `should_return`.
	bool should_print_usage() const;

	bool refresh_on_start() const;

	nonstd::optional<std::string> url_file() const;

	nonstd::optional<std::string> lock_file() const;

	nonstd::optional<std::string> cache_file() const;

	nonstd::optional<std::string> config_file() const;

	/// If non-empty, Newsboat should execute these commands and then quit.
	///
	/// \note The parser does not check if the passed commands are valid.
	std::vector<std::string> cmds_to_execute() const;

	nonstd::optional<std::string> log_file() const;

	nonstd::optional<Level> log_level() const;

	/// Returns the reference to the Rust object.
	///
	/// This is only meant to be used in situations when one wants to pass
	/// a reference back to Rust.
	const cliargsparser::bridged::CliArgsParser& get_rust_ref() const;

private:
	rust::Box<cliargsparser::bridged::CliArgsParser> rs_object;
};
} // namespace newsboat

#endif /* NEWSBOAT_CLIARGSPARSER_H_ */