Commit 7af644f7 authored by Lisa's avatar Lisa

Useless checks removed from command line code

parent 46de3c16
......@@ -184,8 +184,6 @@ CmdLine::CmdLine()
/* These are the only operation we need to access directly later, so better speed up searches a bit */
specialOperations.insert(APM::RemoveAllCache, removeallcache);
specialOperations.insert(APM::Help, help);
specialOperations.insert(APM::Version, version);
specialOperations.insert(APM::Install, install);
}
......@@ -309,54 +307,42 @@ void CmdLine::parse(int argc, char** argv)
m_type = APM::NoType;
QSet<QByteArray> found;
/*
* These are considered separately and when found, they surpass any other operation that may be present.
*/
if (args->isSet("h")) {
AkabeiOperation help = specialOperations[APM::Help];
m_operations.insert(APM::Help, help);
} else if (args->isSet("v")) {
AkabeiOperation version = specialOperations[APM::Version];
m_operations.insert(APM::Version, version);
}
else {
for (QHash<QByteArray, APM::OperationType>::iterator it = typechars.begin(); it != typechars.end(); it++) {
if (args->isSet(it.key())) {
if (m_type != APM::NoType) {
throw CmdLineException("multiple types present.");
}
m_type = it.value();
if (m_type == APM::QueryOperationType) {
found << "Q";
}
for (QHash<QByteArray, APM::OperationType>::iterator it = typechars.begin(); it != typechars.end(); it++) {
if (args->isSet(it.key())) {
if (m_type != APM::NoType) {
throw CmdLineException("multiple types present.");
}
m_type = it.value();
if (m_type == APM::QueryOperationType) {
found << "Q";
}
/*
* We look only for the acceptable operations
* all the others, if present, will be spotted later
*/
foreach (AkabeiOperation op, acceptedOperations.values(m_type)) {
/*
* We look only for the acceptable operations
* all the others, if present, will be spotted later
*/
foreach (AkabeiOperation op, acceptedOperations.values(m_type)) {
/*
* Saves up the commands for later inspection
*/
if (args->isSet(op.commandShort)) {
m_operations.insert(op.name, op);
found << op.commandShort;
if (!op.commandLong.isEmpty()) {
found << op.commandLong;
}
* Saves up the commands for later inspection
*/
if (args->isSet(op.commandShort)) {
m_operations.insert(op.name, op);
found << op.commandShort;
if (!op.commandLong.isEmpty()) {
found << op.commandLong;
}
}
/*
* This kind of command is unfortunately completely ignored (-S -cc is fine)
* so we have to check it separately. Again, malformed versions will be spotted later
*/
if (KCmdLineArgs::allArguments().contains("-Scc")) {
AkabeiOperation special = specialOperations[APM::RemoveAllCache];
m_operations.insert(special.name, special);
found << special.commandShort;
}
}
/*
* This kind of command is unfortunately completely ignored (-S -cc is fine)
* so we have to check it separately. Again, malformed versions will be spotted later
*/
if (KCmdLineArgs::allArguments().contains("-Scc")) {
AkabeiOperation special = specialOperations[APM::RemoveAllCache];
m_operations.insert(special.name, special);
found << special.commandShort;
}
}
}
......
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