#pragma once #include #include // Command-line front-end: what `pacmanager ` asks for, parsed apart // from everything that runs it so the grammar can be unit-tested without a // package manager, a display or a single process spawned. // // The wording is the one of the issue that asked for it: a simplified pacman, // `pacmanager recherche vlc` then `pacmanager install vlc`. French is the // language the rest of the interface is written in, so its keywords come first; // the English ones are accepted as aliases because the second half of that same // sentence is English. namespace cli { enum class Command { // No argument at all: the window is wanted. None, Search, Install, Remove, // No operand updates everything; one operand updates that package. Update, List, Updates, Info, Refresh, Cleanup, Help, Version, // Something was typed that is not a command: `error` says what. Unknown, }; struct Parsed { Command command = Command::None; // Package names, or the search term for Search. QStringList operands; // Skip the confirmation of a destructive command. bool assumeYes = false; // Why parsing refused, when command == Unknown. QString error; }; // True when the arguments ask for the command line rather than the window. // The absence of a known keyword is what keeps // "pacmanager /chemin/app.flatpak" opening the window, the way the desktop // entry hands a file over. bool isCliInvocation(const QStringList& args); // Parses the arguments, program name excluded. Parsed parse(const QStringList& args); // The text `pacmanager --help` prints. QString helpText(); } // namespace cli