Commit d64928f9 authored by Lisa's avatar Lisa

Some refactoring around

parent b919153d
...@@ -44,6 +44,7 @@ public: ...@@ -44,6 +44,7 @@ public:
ShowUpgradeable, ShowUpgradeable,
ShowLess, ShowLess,
///Sync operations ///Sync operations
Install,
AsDeps,//Also in upgrade AsDeps,//Also in upgrade
AsExplicit,//Also in upgrade AsExplicit,//Also in upgrade
RemoveOldPackages, RemoveOldPackages,
...@@ -59,6 +60,7 @@ public: ...@@ -59,6 +60,7 @@ public:
UpdateDatabases, UpdateDatabases,
UpdateSystem, UpdateSystem,
///Remove operations ///Remove operations
Remove,
Cascade, Cascade,
DatabaseOnly,//Also in upgrade DatabaseOnly,//Also in upgrade
RemoveConfig, RemoveConfig,
......
...@@ -164,6 +164,8 @@ int main(int argc, char** argv) ...@@ -164,6 +164,8 @@ int main(int argc, char** argv)
list.append(APM::ShowLess); list.append(APM::ShowLess);
} else if (args->isSet("R")) { } else if (args->isSet("R")) {
type = APM::RemoveOperationType; type = APM::RemoveOperationType;
list.append(APM::Remove);
if (args->isSet("c")) if (args->isSet("c"))
list.append(APM::Cascade); list.append(APM::Cascade);
if (args->isSet("d")) if (args->isSet("d"))
...@@ -178,6 +180,8 @@ int main(int argc, char** argv) ...@@ -178,6 +180,8 @@ int main(int argc, char** argv)
list.append(APM::Unneeded); list.append(APM::Unneeded);
} else if (args->isSet("S")) { } else if (args->isSet("S")) {
type = APM::SyncOperationType; type = APM::SyncOperationType;
list.append(APM::Install);
if (args->isSet("y")) if (args->isSet("y"))
list.append(APM::UpdateDatabases); list.append(APM::UpdateDatabases);
if (args->isSet("u")) if (args->isSet("u"))
...@@ -229,8 +233,9 @@ int main(int argc, char** argv) ...@@ -229,8 +233,9 @@ int main(int argc, char** argv)
if (args->isSet("w")) if (args->isSet("w"))
list.append(APM::DownloadOnly); list.append(APM::DownloadOnly);
} else { } else {
fprintf(stderr, "Please select an operation to do!\nCall akabei --help for explanation.\n"); QTextStream err(stderr);
return app.exec(); err << "Please select an operation to do!\nCall akabei --help for explanation.\n";
return -1;
} }
QString root = args->getOption("root"); QString root = args->getOption("root");
opts.insert(APM::RootDir, root); opts.insert(APM::RootDir, root);
...@@ -241,6 +246,15 @@ int main(int argc, char** argv) ...@@ -241,6 +246,15 @@ int main(int argc, char** argv)
QString cache = args->getOption("cachedir"); QString cache = args->getOption("cachedir");
opts.insert(APM::CacheDir, cache); opts.insert(APM::CacheDir, cache);
/*
* APM::Remove or APM::Install must remain only when they're alone
* otherwise another operation has been requested
*/
if (list.size() > 1) {
list.removeOne(APM::Remove);
list.removeOne(APM::Install);
}
QStringList rest; QStringList rest;
for (int i = 0; i < args->count(); i++) { for (int i = 0; i < args->count(); i++) {
...@@ -250,6 +264,5 @@ int main(int argc, char** argv) ...@@ -250,6 +264,5 @@ int main(int argc, char** argv)
args->clear(); // Free up some memory args->clear(); // Free up some memory
APM apm(type, list, opts, rest); APM apm(type, list, opts, rest);
return app.exec(); return app.exec();
} }
This diff is collapsed.
...@@ -40,7 +40,9 @@ private slots: ...@@ -40,7 +40,9 @@ private slots:
private: private:
int m_currentDatabasePos; int m_currentDatabasePos;
int m_maxDbNameLenght; int m_maxDbNameLenght;
void updateNextDatabase(); void updateNextDatabase();
void nextOperation();
QList<APM::Operation> m_operations; QList<APM::Operation> m_operations;
QMultiHash<APM::Operation, QString> m_options; QMultiHash<APM::Operation, QString> m_options;
......
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