Commit 44aafcd1 authored by Lukas Appelhans's avatar Lukas Appelhans

Put all the -S stuff in... make actual text-options work

parent cfa33eb6
...@@ -19,10 +19,11 @@ ...@@ -19,10 +19,11 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QTimer> #include <QTimer>
APM::APM(OperationType type, QList<Operation> operations, QStringList args, QObject * parent) APM::APM(OperationType type, QList<Operation> operations, QMultiHash<Operation, QString> options, QStringList args, QObject * parent)
: QObject(parent), : QObject(parent),
m_operationType(type), m_operationType(type),
m_operations(operations), m_operations(operations),
m_options(options),
m_args(args) m_args(args)
{ {
......
...@@ -33,8 +33,8 @@ public: ...@@ -33,8 +33,8 @@ public:
ShowChangelog, ShowChangelog,
ShowInstalledAsDeps, ShowInstalledAsDeps,
ShowInstalledExplicitely, ShowInstalledExplicitely,
ShowPackagesOfGroup, ShowPackagesOfGroup, //Also in Sync
ShowInformation, ShowInformation, //Also in Sync
CheckFiles, CheckFiles,
ShowLocal, ShowLocal,
ShowOwner, ShowOwner,
...@@ -44,10 +44,22 @@ public: ...@@ -44,10 +44,22 @@ public:
ShowUpgradeable, ShowUpgradeable,
ShowLess, ShowLess,
///Sync operations ///Sync operations
AsDeps,
AsExplicit,
RemoveOldPackages,
RemoveAllPackages,
SkipDependencyCheck,
Force,
ListRepo,
Search,
DownloadOnly,
OnlyNeeded,
Ignore,
IgnoreGroup,
UpdateDatabases, UpdateDatabases,
UpdateSystem UpdateSystem
}; };
explicit APM(OperationType type, QList<Operation> operations, QStringList args, QObject* parent = 0); explicit APM(OperationType type, QList<Operation> operations, QMultiHash<Operation, QString> options, QStringList args, QObject* parent = 0);
virtual ~APM(); virtual ~APM();
private slots: private slots:
...@@ -57,6 +69,7 @@ private slots: ...@@ -57,6 +69,7 @@ private slots:
private: private:
OperationType m_operationType; OperationType m_operationType;
QList<Operation> m_operations; QList<Operation> m_operations;
QMultiHash<Operation, QString> m_options;
QStringList m_args; QStringList m_args;
}; };
......
...@@ -49,6 +49,20 @@ int main(int argc, char** argv) ...@@ -49,6 +49,20 @@ int main(int argc, char** argv)
options.add("R", ki18n("Remove operation")); options.add("R", ki18n("Remove operation"));
options.add("S", ki18n("Sync operation")); options.add("S", ki18n("Sync operation"));
options.add("asdeps", ki18n("Install all packages as non-explicit"));
options.add("asexplicit", ki18n("Install all packages as explicit"));
options.add("c", ki18n("Remove old packages from cache"));
options.add("cc", ki18n("Remove all packages from cache"));
options.add("d", ki18n("Skip dependency check"));
options.add("f", ki18n("Force installation. Overwrite file conflicts"));
options.add("g", ki18n("Show all packages in a group"));
options.add("i", ki18n("Show package information"));
options.add("l", ki18n("List all packages of a specific repository"));
options.add("s", ki18n("Searches repositories for a word"));
options.add("w", ki18n("Downloads packages without installing or upgrading them"));
options.add("needed", ki18n("Up-to-date packages are not reinstalled"));
options.add("ignore <package>", ki18n("Ignores a certain package. Can be used more than once."));
options.add("ignoregroup <group>", ki18n("Ignores upgrade of a group"));
options.add("y", ki18n("Refresh database")); options.add("y", ki18n("Refresh database"));
options.add("u", ki18n("Update system")); options.add("u", ki18n("Update system"));
...@@ -72,6 +86,7 @@ int main(int argc, char** argv) ...@@ -72,6 +86,7 @@ int main(int argc, char** argv)
QList<APM::Operation> list; QList<APM::Operation> list;
APM::OperationType type = APM::NoType; APM::OperationType type = APM::NoType;
QMultiHash<APM::Operation, QString> opts;
if (args->isSet("D")) { if (args->isSet("D")) {
type = APM::DatabaseOperationType; type = APM::DatabaseOperationType;
...@@ -107,10 +122,44 @@ int main(int argc, char** argv) ...@@ -107,10 +122,44 @@ int main(int argc, char** argv)
type = APM::RemoveOperationType; type = APM::RemoveOperationType;
} else if (args->isSet("S")) { } else if (args->isSet("S")) {
type = APM::SyncOperationType; type = APM::SyncOperationType;
if (args->isSet("asdeps"))
list.append(APM::AsDeps);
if (args->isSet("asexplicit"))
list.append(APM::AsExplicit);
if (args->isSet("c"))
list.append(APM::RemoveOldPackages);
if (args->isSet("cc"))
list.append(APM::RemoveAllPackages);
if (args->isSet("d"))
list.append(APM::SkipDependencyCheck);
if (args->isSet("f"))
list.append(APM::Force);
if (args->isSet("g"))
list.append(APM::ShowPackagesOfGroup);
if (args->isSet("i"))
list.append(APM::ShowInformation);
if (args->isSet("l"))
list.append(APM::ListRepo);
if (args->isSet("s"))
list.append(APM::Search);
if (args->isSet("w"))
list.append(APM::DownloadOnly);
if (args->isSet("needed"))
list.append(APM::OnlyNeeded);
if (args->isSet("y")) if (args->isSet("y"))
list.append(APM::UpdateDatabases); list.append(APM::UpdateDatabases);
if (args->isSet("u")) if (args->isSet("u"))
list.append(APM::UpdateSystem); list.append(APM::UpdateSystem);
QStringList ignore = args->getOptionList("ignore");
if (!ignore.isEmpty()) {
foreach (const QString &ign, ignore)
opts.insert(APM::Ignore, ign);
}
QStringList ignoreGroup = args->getOptionList("ignoregroup");
if (!ignoreGroup.isEmpty()) {
foreach (const QString &ign, ignoreGroup)
opts.insert(APM::IgnoreGroup, ign);
}
} else if (args->isSet("U")) { } else if (args->isSet("U")) {
type = APM::UpgradeOperationType; type = APM::UpgradeOperationType;
} else { } else {
...@@ -126,7 +175,7 @@ int main(int argc, char** argv) ...@@ -126,7 +175,7 @@ int main(int argc, char** argv)
args->clear(); // Free up some memory args->clear(); // Free up some memory
APM apm(type, list, rest); APM apm(type, list, opts, rest);
return app.exec(); return app.exec();
} }
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
//TODO: Make the -p stuff work!
QueryOperation::QueryOperation(QObject * parent) QueryOperation::QueryOperation(QObject * parent)
: QObject(parent) : QObject(parent)
{ {
...@@ -36,7 +34,7 @@ QueryOperation::~QueryOperation() ...@@ -36,7 +34,7 @@ QueryOperation::~QueryOperation()
} }
void QueryOperation::start(QList<APM::Operation> operations, QStringList args) void QueryOperation::start(QList<APM::Operation> operations, QStringList args)
{ { //TODO: Make it all only query the local database
if (operations.contains(APM::ShowInformation)) { if (operations.contains(APM::ShowInformation)) {
if (args.isEmpty()) if (args.isEmpty())
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment