Files
FWS-PacManage/cli/cli-command.h
BlackAngelTV 3e4ed92c0a feat(cli): add a simplified command line over the logic layer
The window needs a display, which kept the package manager out of a script and
off a headless machine. The command line runs the same operations through
AppCore, before any widget exists, so providers, the pacman lock, the journal
and the history behave exactly as in the window.

Refs #22.
2026-10-03 22:53:47 +02:00

59 lines
1.7 KiB
C++

#pragma once
#include <QString>
#include <QStringList>
// Command-line front-end: what `pacmanager <commande>` 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