Skip to content

Commit cbf3a52

Browse files
committed
misc: some docs
1 parent 9b3ee62 commit cbf3a52

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

include/libcufetch/common.hh

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131

3232
constexpr const char NOCOLOR[] = "\033[0m";
3333
constexpr const char NOCOLOR_BOLD[] = "\033[0m\033[1m";
34+
35+
// Didn't find what you were looking for.
3436
constexpr const char UNKNOWN[] = "(unknown)";
3537

36-
// Usually in neofetch/fastfetch when some infos couldn't be queried,
37-
// they remove it from the display. With customfetch is kinda difficult to know when to remove
38-
// the info to display, since it's all modular with tags, so I have created
39-
// magic line to be sure that I don't cut the wrong line.
38+
// Usually in neofetch/fastfetch when some infos couldn't be queried, they remove it from the display.
39+
// With customfetch is kinda difficult to know when to remove the info to display,
40+
// since it's all modular with tags, so I have created a "magic line" to be sure that I don't cut the wrong line.
4041
//
41-
// Every instance of this string in a layout line, the whole line will be erased.
42+
// Every instance of this string found in a layout line, the whole line will be erased.
4243
constexpr const char MAGIC_LINE[] = "(cut this line NOW!! RAHHH)";
4344

4445
#define APICALL extern "C"
@@ -52,39 +53,50 @@ inline bool debug_print = true;
5253
inline bool debug_print = false;
5354
#endif
5455

56+
// std::format function arguments
57+
// Print to stderr an error with header 'ERROR:' in red
5558
template <typename... Args>
5659
void error(const std::string_view fmt, Args&&... args) noexcept
5760
{
5861
fmt::print(stderr, "\033[1;31mERROR: {}\033[0m\n",
5962
fmt::format(fmt::runtime(fmt), std::forward<Args>(args)...));
6063
}
6164

65+
// std::format function arguments
66+
// Print to stderr an error with header 'FATAL:' in red and exit with failure code
6267
template <typename... Args>
6368
void die(const std::string_view fmt, Args&&... args) noexcept
6469
{
6570
fmt::print(stderr, "\033[1;31mFATAL: {}\033[0m\n",
6671
fmt::format(fmt::runtime(fmt), std::forward<Args>(args)...));
67-
std::exit(1);
72+
std::exit(EXIT_FAILURE);
6873
}
6974

75+
// std::format function arguments
76+
// Print to stdout a debug msg with header '[DEBUG]' in hot-pink color
77+
// only if debug_print is set (do not modify it).
7078
template <typename... Args>
7179
void debug(const std::string_view fmt, Args&&... args) noexcept
7280
{
7381
if (debug_print)
74-
fmt::print("\033[1;38;2;255;105;180m[DEBUG]:\033[0m {}\n",
82+
fmt::print(stdout, "\033[1;38;2;255;105;180m[DEBUG]:\033[0m {}\n",
7583
fmt::format(fmt::runtime(fmt), std::forward<Args>(args)...));
7684
}
7785

86+
// std::format function arguments
87+
// Print to stderr a warning with header 'WARNING:' in yellow
7888
template <typename... Args>
7989
void warn(const std::string_view fmt, Args&&... args) noexcept
8090
{
81-
fmt::print("\033[1;33mWARNING: {}\033[0m\n",
91+
fmt::print(stderr, "\033[1;33mWARNING: {}\033[0m\n",
8292
fmt::format(fmt::runtime(fmt), std::forward<Args>(args)...));
8393
}
8494

95+
// std::format function arguments
96+
// Print to stdout an info msg with header 'INFO:' in cyan
8597
template <typename... Args>
8698
void info(const std::string_view fmt, Args&&... args) noexcept
8799
{
88-
fmt::print("\033[1;36mINFO: {}\033[0m\n",
100+
fmt::print(stdout, "\033[1;36mINFO: {}\033[0m\n",
89101
fmt::format(fmt::runtime(fmt), std::forward<Args>(args)...));
90102
}

include/libcufetch/cufetch.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#include <string>
55
#include <vector>
66

7-
#include "libcufetch/parse.hh"
7+
#include "libcufetch/common.hh"
8+
struct parse_args_t;
89

910
/* A linked list including module arguments. An argument may be specified for any part of the module path (e.g.
1011
* `disk(/).used(GiB)`, `test.hi(a)`) */

include/libcufetch/parse.hh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "libcufetch/common.hh"
88
#include "libcufetch/config.hh"
9+
#include "libcufetch/cufetch.hh"
910

1011
// C ABI is needed to prevent symbol mangling, but we don't actually need C compatibility,
1112
// so we ignore this warning about return types that are potentially incompatible with C.
@@ -14,8 +15,6 @@
1415
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
1516
#endif
1617

17-
struct module_t;
18-
1918
// Map from a modules name to its pointer.
2019
using moduleMap_t = std::unordered_map<std::string, const module_t&>;
2120

0 commit comments

Comments
 (0)