Skip to content

Commit

Permalink
Add help, verbose and quiet args
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Aug 28, 2023
1 parent a498822 commit 965c461
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/helpers/Log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@ enum eLogLevel
#define ASSERT(expr) RASSERT(expr, "?")

namespace Debug {
inline bool quiet = false;
inline bool verbose = false;

template <typename... Args>
void log(eLogLevel level, const std::string& fmt, Args&&... args) {

if (!verbose && level == TRACE)
return;

if (quiet)
return;

std::cout << '[';

switch (level) {
Expand Down
30 changes: 29 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,38 @@
#include "helpers/Log.hpp"
#include "core/PortalManager.hpp"

void printHelp() {
std::cout << R"#(| xdg-desktop-portal-hyprland
| --------------------------------------
| -v (--verbose) > enable trace logging
| -q (--quiet) > disable logging
| -h (--help) > print this menu
)#";
}

int main(int argc, char** argv, char** envp) {
g_pPortalManager = std::make_unique<CPortalManager>();

for (int i = 1; i < argc; ++i) {
std::string arg = argv[i];

if (arg == "--verbose" || arg == "-v")
Debug::verbose = true;

else if (arg == "--quiet" || arg == "-q")
Debug::quiet = true;

else if (arg == "--help" || arg == "-h") {
printHelp();
return 0;
} else {
printHelp();
return 1;
}
}

Debug::log(LOG, "Initializing xdph...");

g_pPortalManager = std::make_unique<CPortalManager>();
g_pPortalManager->init();

return 0;
Expand Down

0 comments on commit 965c461

Please sign in to comment.