Commit d64928f9 authored by Lisa's avatar Lisa

Some refactoring around

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