16#include <unordered_map> 
   20  "org.mpris.MediaPlayer2.inLimbo"; 
 
   72    static const std::unordered_map<ConsoleColor, std::string_view> colorCodes = {
 
   77    return colorCodes.at(color);
 
 
 
  122    const std::unordered_map<std::string, std::function<void()>> argumentHandlers = {
 
  123      {
"--help", [&]() { handleHelp(cmdArgs, programName); }},
 
  124      {
"--version", [&]() { handleVersion(); }},
 
  125      {
"--clear-cache", [&]() { handleClearCache(paths.
libBinPath); }},
 
  126      {
"--show-config-file", [&]() { handleShowConfig(paths.
configPath); }},
 
  127      {
"--show-log-dir", [&]() { handleShowLogDir(paths.
cacheDir); }},
 
  128      {
"--show-dbus-name", [&]() { handleShowDBusName(); }},
 
  129      {
"--update-cache-run", [&]() { handleUpdateCacheRun(paths.
libBinPath); }},
 
  130      {
"--print-song-tree", [&]() { handlePrintSongTree(); }},
 
  131      {
"--print-artists-all", [&]() { handlePrintArtistsAll(); }},
 
  132      {
"--print-songs-by-genre-all", [&]() { handlePrintSongsByGenreAll(); }},
 
  133      {
"--print-songs-by-artist",
 
  134       [&]() { handlePrintSongsByArtist(cmdArgs.
get(
"--print-songs-by-artist")); }},
 
  135      {
"--print-song-info", [&]() { handleSongInfo(cmdArgs.
get(
"--print-song-info")); }}};
 
  137    for (
const auto& [flag, handler] : argumentHandlers)
 
 
  157      song_tree.printAllArtists();
 
  167      song_tree.getSongsByGenreAndPrint();
 
 
  183  static void colorPrint(
ConsoleColor color, std::string_view label, std::string_view value = 
"")
 
  195  static void handleHelp(
const CommandLineArgs& cmdArgs, 
const std::string& programName)
 
  200  static auto readVersionFromFile() -> std::string
 
  205      std::cerr << 
"Error: Unable to open VERSION file!" << std::endl;
 
  206      return "Unknown Version"; 
 
  209    std::stringstream buffer;
 
  210    buffer << versionFile.rdbuf(); 
 
  217  static void handleVersion()
 
  219    std::string version = readVersionFromFile();
 
  228  static void handleShowConfig(
const std::string& configPath)
 
  238  static void handleShowLogDir(
const std::string& cacheDir)
 
  246  static void handleShowDBusName()
 
  259  static void handleClearCache(
const std::string& libBinPath)
 
  263      if (std::filesystem::exists(libBinPath))
 
  265        std::filesystem::remove(libBinPath);
 
  273    catch (
const std::filesystem::filesystem_error& e)
 
  287  static void handleUpdateCacheRun(
const std::string& libBinPath)
 
  290              << 
"-- Updating Cache and running app..." 
  292    handleClearCache(libBinPath);
 
  296  static void parseSongMap()
 
  302  static void handlePrintSongTree()
 
  308  static void handlePrintArtistsAll()
 
  314  static void handlePrintSongsByArtist(std::string artistName)
 
  320  static void handlePrintSongsByGenreAll()
 
  325  static void handleSongInfo(std::string songName)
 
 
constexpr const char * REPOSITORY_URL
Definition arg-handler.hpp:22
 
bool parseSongTree
Definition arg-handler.hpp:26
 
constexpr const char * DBUS_SERVICE_NAME
DBus service name used by inLimbo.
Definition arg-handler.hpp:19
 
ConsoleColor
Represents ANSI console colors for colored output.
Definition arg-handler.hpp:44
 
@ Cyan
Cyan color code.
Definition arg-handler.hpp:50
 
@ Yellow
Yellow color code.
Definition arg-handler.hpp:48
 
@ Reset
Resets the console color to default.
Definition arg-handler.hpp:45
 
@ Blue
Blue color code.
Definition arg-handler.hpp:47
 
@ Magenta
Magenta color code.
Definition arg-handler.hpp:51
 
@ Green
Green color code.
Definition arg-handler.hpp:46
 
@ Red
Red color code.
Definition arg-handler.hpp:49
 
constexpr const char * VERSION_FILE_NAME
Definition arg-handler.hpp:21
 
bool shouldRunApp
Indicates if the application should proceed to run after handling arguments.
Definition arg-handler.hpp:24
 
Handles processing of command-line arguments and executes corresponding actions.
Definition arg-handler.hpp:90
 
static void handleArguments(const CommandLineArgs &cmdArgs, const std::string &programName, const Paths &paths)
Handles command-line arguments and executes corresponding actions.
Definition arg-handler.hpp:119
 
static auto processSongTreeArguments(SongTree &song_tree) -> void
Definition arg-handler.hpp:148
 
static SongTreeState song_tree_parse_state
Definition arg-handler.hpp:106
 
Provides utilities for managing console colors.
Definition arg-handler.hpp:62
 
static auto getColor(ConsoleColor color) -> std::string_view
Retrieves the ANSI color code for a given ConsoleColor.
Definition arg-handler.hpp:70
 
Parses and validates command-line arguments.
Definition cmd-line-args.hpp:26
 
void printUsage(const std::string &programName) const
Prints usage information and program details.
Definition cmd-line-args.hpp:103
 
auto hasFlag(const std::string &flag) const -> bool
Checks if a specific flag was provided.
Definition cmd-line-args.hpp:80
 
auto get(const std::string &flag, const std::string &defaultValue="") const -> std::string
Retrieves the value associated with a flag.
Definition cmd-line-args.hpp:67
 
Represents a hierarchical tree structure to store songs by artist, album, disc number,...
Definition songmap.hpp:90
 
Represents essential application paths.
Definition arg-handler.hpp:100
 
std::string libBinPath
Path to the binary library.
Definition arg-handler.hpp:102
 
std::string configPath
Path to the configuration file.
Definition arg-handler.hpp:101
 
std::string cacheDir
Path to the cache directory.
Definition arg-handler.hpp:103
 
Definition arg-handler.hpp:29
 
bool printSongTree
Definition arg-handler.hpp:30
 
std::string artist
Definition arg-handler.hpp:35
 
bool printArtistsAll
Definition arg-handler.hpp:31
 
bool printSongInfo
Definition arg-handler.hpp:34
 
bool printSongsByArtist
Definition arg-handler.hpp:32
 
std::string song
Definition arg-handler.hpp:36
 
bool printSongsGenreAll
Definition arg-handler.hpp:33