Skip to content

Commit 005baea

Browse files
committed
style: apply clang-format
1 parent 96cc2b7 commit 005baea

33 files changed

Lines changed: 18892 additions & 17432 deletions

src/btop.cpp

Lines changed: 1135 additions & 1098 deletions
Large diffs are not rendered by default.

src/btop_cli.cpp

Lines changed: 206 additions & 212 deletions
Large diffs are not rendered by default.

src/btop_cli.hpp

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,44 @@
1010
#include <string_view>
1111

1212
namespace Cli {
13-
namespace stdfs = std::filesystem;
14-
15-
// Configuration options set via the command line.
16-
struct Cli {
17-
// Alternate path to a configuration file
18-
std::optional<stdfs::path> config_file;
19-
// Enable debug mode with additional logs and metrics
20-
bool debug {};
21-
// Set an initial process filter.
22-
std::optional<std::string> filter;
23-
// Only use ANSI supported graph symbols and colors
24-
std::optional<bool> force_tty;
25-
// Use UTF-8 locale even if not detected
26-
bool force_utf {};
27-
// Disable true color and only use 256 color mode
28-
bool low_color {};
29-
// Start with one of the provided presets
30-
std::optional<std::uint32_t> preset;
31-
// Path to a custom themes directory
32-
std::optional<stdfs::path> themes_dir;
33-
// The initial refresh rate
34-
std::optional<std::uint32_t> updates;
35-
};
36-
37-
using Result = std::expected<Cli, std::int32_t>;
38-
39-
// Parse the command line arguments
40-
[[nodiscard]] auto parse(std::span<const std::string_view> args) noexcept -> Result;
41-
42-
// Print default config to standard output
43-
[[nodiscard]] auto default_config() noexcept -> Result;
44-
45-
// Print a usage header
46-
void usage() noexcept;
47-
48-
// Print a help message
49-
void help() noexcept;
50-
51-
// Print a hint on how to show more help
52-
void help_hint() noexcept;
13+
namespace stdfs = std::filesystem;
14+
15+
// Configuration options set via the command line.
16+
struct Cli {
17+
// Alternate path to a configuration file
18+
std::optional<stdfs::path> config_file;
19+
// Enable debug mode with additional logs and metrics
20+
bool debug {};
21+
// Set an initial process filter.
22+
std::optional<std::string> filter;
23+
// Only use ANSI supported graph symbols and colors
24+
std::optional<bool> force_tty;
25+
// Use UTF-8 locale even if not detected
26+
bool force_utf {};
27+
// Disable true color and only use 256 color mode
28+
bool low_color {};
29+
// Start with one of the provided presets
30+
std::optional<std::uint32_t> preset;
31+
// Path to a custom themes directory
32+
std::optional<stdfs::path> themes_dir;
33+
// The initial refresh rate
34+
std::optional<std::uint32_t> updates;
35+
};
36+
37+
using Result = std::expected<Cli, std::int32_t>;
38+
39+
// Parse the command line arguments
40+
[[nodiscard]] auto parse(std::span<const std::string_view> args) noexcept -> Result;
41+
42+
// Print default config to standard output
43+
[[nodiscard]] auto default_config() noexcept -> Result;
44+
45+
// Print a usage header
46+
void usage() noexcept;
47+
48+
// Print a help message
49+
void help() noexcept;
50+
51+
// Print a hint on how to show more help
52+
void help_hint() noexcept;
5353
} // namespace Cli

src/btop_config.cpp

Lines changed: 810 additions & 755 deletions
Large diffs are not rendered by default.

src/btop_config.hpp

Lines changed: 99 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at
66
7-
http://www.apache.org/licenses/LICENSE-2.0
7+
http://www.apache.org/licenses/LICENSE-2.0
88
99
Unless required by applicable law or agreed to in writing, software
1010
distributed under the License is distributed on an "AS IS" BASIS,
@@ -21,120 +21,140 @@ tab-size = 4
2121
#include <filesystem>
2222
#include <optional>
2323
#include <string>
24-
#include <vector>
25-
2624
#include <unordered_map>
25+
#include <vector>
2726

2827
using std::string;
2928
using std::vector;
3029

3130
//* Functions and variables for reading and writing the btop config file
3231
namespace Config {
3332

34-
extern std::filesystem::path conf_dir;
35-
extern std::filesystem::path conf_file;
36-
37-
extern std::unordered_map<std::string_view, string> strings;
38-
extern std::unordered_map<std::string_view, string> stringsTmp;
39-
extern std::unordered_map<std::string_view, bool> bools;
40-
extern std::unordered_map<std::string_view, bool> boolsTmp;
41-
extern std::unordered_map<std::string_view, int> ints;
42-
extern std::unordered_map<std::string_view, int> intsTmp;
43-
44-
const vector<string> valid_graph_symbols = { "braille", "block", "tty" };
45-
const vector<string> valid_graph_symbols_def = { "default", "braille", "block", "tty" };
46-
const vector<string> valid_boxes = {
47-
"cpu", "mem", "net", "proc"
33+
extern std::filesystem::path conf_dir;
34+
extern std::filesystem::path conf_file;
35+
36+
extern std::unordered_map<std::string_view, string> strings;
37+
extern std::unordered_map<std::string_view, string> stringsTmp;
38+
extern std::unordered_map<std::string_view, bool> bools;
39+
extern std::unordered_map<std::string_view, bool> boolsTmp;
40+
extern std::unordered_map<std::string_view, int> ints;
41+
extern std::unordered_map<std::string_view, int> intsTmp;
42+
43+
const vector<string> valid_graph_symbols = {"braille", "block", "tty"};
44+
const vector<string> valid_graph_symbols_def = {"default", "braille", "block", "tty"};
45+
const vector<string> valid_boxes = {
46+
"cpu",
47+
"mem",
48+
"net",
49+
"proc"
4850
#ifdef GPU_SUPPORT
49-
,"gpu0", "gpu1", "gpu2", "gpu3", "gpu4", "gpu5"
51+
,
52+
"gpu0",
53+
"gpu1",
54+
"gpu2",
55+
"gpu3",
56+
"gpu4",
57+
"gpu5"
5058
#endif
51-
};
52-
const vector<string> temp_scales = { "celsius", "fahrenheit", "kelvin", "rankine" };
59+
};
60+
const vector<string> temp_scales = {"celsius", "fahrenheit", "kelvin", "rankine"};
5361
#ifdef __linux__
54-
const vector<string> freq_modes = { "first", "range", "lowest", "highest", "average" };
62+
const vector<string> freq_modes = {"first", "range", "lowest", "highest", "average"};
5563
#endif
5664
#ifdef GPU_SUPPORT
57-
const vector<string> show_gpu_values = { "Auto", "On", "Off" };
65+
const vector<string> show_gpu_values = {"Auto", "On", "Off"};
5866
#endif
59-
const vector<string> base_10_bitrate_values = { "Auto", "True", "False" };
60-
extern vector<string> current_boxes;
61-
extern vector<string> preset_list;
62-
extern vector<string> available_batteries;
63-
extern int current_preset;
67+
const vector<string> base_10_bitrate_values = {"Auto", "True", "False"};
68+
extern vector<string> current_boxes;
69+
extern vector<string> preset_list;
70+
extern vector<string> available_batteries;
71+
extern int current_preset;
6472

65-
extern bool write_new;
73+
extern bool write_new;
6674

67-
constexpr int ONE_DAY_MILLIS = 1000 * 60 * 60 * 24;
75+
constexpr int ONE_DAY_MILLIS = 1000 * 60 * 60 * 24;
6876

69-
[[nodiscard]] std::optional<std::filesystem::path> get_config_dir() noexcept;
77+
[[nodiscard]] std::optional<std::filesystem::path> get_config_dir() noexcept;
7078

71-
//* Check if string only contains space separated valid names for boxes and set current_boxes
72-
bool set_boxes(const string& boxes);
79+
//* Check if string only contains space separated valid names for boxes and set current_boxes
80+
bool set_boxes(const string& boxes);
7381

74-
bool validBoxSizes(const string& boxes);
82+
bool validBoxSizes(const string& boxes);
7583

76-
//* Toggle box and update config string shown_boxes
77-
bool toggle_box(const string& box);
84+
//* Toggle box and update config string shown_boxes
85+
bool toggle_box(const string& box);
7886

79-
//* Parse and setup config value presets
80-
bool presetsValid(const string& presets);
87+
//* Parse and setup config value presets
88+
bool presetsValid(const string& presets);
8189

82-
//* Apply selected preset
83-
bool apply_preset(const string& preset);
90+
//* Apply selected preset
91+
bool apply_preset(const string& preset);
8492

85-
bool _locked(const std::string_view name);
93+
bool _locked(const std::string_view name);
8694

87-
//* Return bool for config key <name>
88-
inline bool getB(const std::string_view name) { return bools.at(name); }
95+
//* Return bool for config key <name>
96+
inline bool getB(const std::string_view name) {
97+
return bools.at(name);
98+
}
8999

90-
//* Return integer for config key <name>
91-
inline const int& getI(const std::string_view name) { return ints.at(name); }
100+
//* Return integer for config key <name>
101+
inline const int& getI(const std::string_view name) {
102+
return ints.at(name);
103+
}
92104

93-
//* Return string for config key <name>
94-
inline const string& getS(const std::string_view name) { return strings.at(name); }
105+
//* Return string for config key <name>
106+
inline const string& getS(const std::string_view name) {
107+
return strings.at(name);
108+
}
95109

96-
string getAsString(const std::string_view name);
110+
string getAsString(const std::string_view name);
97111

98-
extern string validError;
112+
extern string validError;
99113

100-
bool intValid(const std::string_view name, const string& value);
101-
bool stringValid(const std::string_view name, const string& value);
114+
bool intValid(const std::string_view name, const string& value);
115+
bool stringValid(const std::string_view name, const string& value);
102116

103-
//* Set config key <name> to bool <value>
104-
inline void set(const std::string_view name, bool value) {
105-
if (_locked(name)) boolsTmp.insert_or_assign(name, value);
106-
else bools.at(name) = value;
107-
}
117+
//* Set config key <name> to bool <value>
118+
inline void set(const std::string_view name, bool value) {
119+
if (_locked(name))
120+
boolsTmp.insert_or_assign(name, value);
121+
else
122+
bools.at(name) = value;
123+
}
108124

109-
//* Set config key <name> to int <value>
110-
inline void set(const std::string_view name, const int value) {
111-
if (_locked(name)) intsTmp.insert_or_assign(name, value);
112-
else ints.at(name) = value;
113-
}
125+
//* Set config key <name> to int <value>
126+
inline void set(const std::string_view name, const int value) {
127+
if (_locked(name))
128+
intsTmp.insert_or_assign(name, value);
129+
else
130+
ints.at(name) = value;
131+
}
114132

115-
//* Set config key <name> to string <value>
116-
inline void set(const std::string_view name, const string& value) {
117-
if (_locked(name)) stringsTmp.insert_or_assign(name, value);
118-
else strings.at(name) = value;
119-
}
133+
//* Set config key <name> to string <value>
134+
inline void set(const std::string_view name, const string& value) {
135+
if (_locked(name))
136+
stringsTmp.insert_or_assign(name, value);
137+
else
138+
strings.at(name) = value;
139+
}
120140

121-
//* Flip config key bool <name>
122-
void flip(const std::string_view name);
141+
//* Flip config key bool <name>
142+
void flip(const std::string_view name);
123143

124-
//* Lock config and cache changes until unlocked
125-
void lock();
144+
//* Lock config and cache changes until unlocked
145+
void lock();
126146

127-
//* Unlock config and write any cached values to config
128-
void unlock();
147+
//* Unlock config and write any cached values to config
148+
void unlock();
129149

130-
//* Load the config file from disk
131-
void load(const std::filesystem::path& conf_file, vector<string>& load_warnings);
150+
//* Load the config file from disk
151+
void load(const std::filesystem::path& conf_file, vector<string>& load_warnings);
132152

133-
//* Write the config file to disk
134-
void write();
153+
//* Write the config file to disk
154+
void write();
135155

136-
auto get_log_file() -> std::optional<std::filesystem::path>;
156+
auto get_log_file() -> std::optional<std::filesystem::path>;
137157

138-
// Write default config to an in-memory buffer
139-
[[nodiscard]] auto current_config() -> std::string;
140-
}
158+
// Write default config to an in-memory buffer
159+
[[nodiscard]] auto current_config() -> std::string;
160+
} // namespace Config

0 commit comments

Comments
 (0)