Commit 74b4d24d authored by Lisa's avatar Lisa
Browse files

Option command fixed; unused option removed. Old commit reverted to fix issues

parent 5acac56f
......@@ -25,13 +25,13 @@
/*
* Adds the options
*/
void initOptions(CommandLineParser *parser)
void initOptions(CommandLineParser *parser, bool isAkabei)
{
parser->addOption(APM::QueryPackageFile, "p", "file", "Queries a file instead of the database", "package-file");
parser->addOption(APM::ShowLess, "q", "quiet", "Shows less information in queries and searches");
parser->addOption(APM::InstallAsDeps, "", "asdeps", "Install all packages as non-explicit");
parser->addOption(APM::InstallAsExplicit, "", "asexplicit", "Install all packages as explicit");
parser->addOption(APM::SkipDependencyCheck, "n", "nodeps", "Skip dependency check");
parser->addOption(APM::SkipDependencyCheck, "d", "nodeps", "Skip dependency check");
parser->addOption(APM::Force, "f", "force", "Force installation. Overwrite file conflicts");
parser->addOption(APM::DownloadOnly, "w", "downloadonly", "Only downloads packages without performing any operation");
parser->addOption(APM::OnlyNeeded, "", "needed", "Up-to-date packages are not reinstalled");
......@@ -43,7 +43,10 @@ void initOptions(CommandLineParser *parser)
parser->addOption(APM::RootDir, "", "root", "Set a different root directory", "directory");
parser->addOption(APM::DBPath, "", "dbpath", "Sets a different database path", "directory");
parser->addOption(APM::CacheDir, "", "cachedir", "Sets a different cache directory", "directory");
parser->addOption(APM::Local, "l", "local", "Shows only packages in the local database");
if (isAkabei) {
parser->addOption(APM::Local, "l", "local", "Shows only packages in the local database");
}
}
void initAkabeiOperations(CommandLineParser *parser)
......@@ -326,11 +329,11 @@ int main(int argc, char **argv)
/* Inits the right parser for the program invoked */
if (arg0 == "akabei") {
parser = new AkabeiParser(argc, argv, aboutData);
initOptions(parser);
initOptions(parser, true);
initAkabeiOperations(parser);
} else if (arg0 == "pakabei") {
parser = new PakabeiParser(argc, argv, aboutData);
initOptions(parser);
initOptions(parser, false);
initPakabeiOperations(parser);
} else {
return -1; /* this should never happen */
......
......@@ -31,6 +31,7 @@ bool CommandLine::isSet(const QString& command)
*/
if (command.size() == 2) {
actualCom = QString::fromAscii("-") + command[0];
m_requested.push_front(actualCom);
if (m_commands.count(actualCom) == 2) {
m_commands.removeAll(actualCom);
......@@ -53,6 +54,7 @@ bool CommandLine::isSet(const QString& command)
m_index = m_commands.indexOf(actualCom);
if (m_index != -1) {
m_requested.push_front(actualCom);
return true;
}
......@@ -87,6 +89,15 @@ QStringList CommandLine::args()
return result;
}
void CommandLine::emptyCheck()
{
foreach (const QString& com, m_commands) {
if (!m_requested.contains(com)) {
throw UnknownOptionException(com);
}
}
}
/*
* Build our database of accepted operations and options with the right properties and associations
*/
......@@ -244,6 +255,8 @@ void PakabeiParser::parse()
if (m_freeArgs.isEmpty() && freeArgsRequired()) {
throw ExpectedArgumentsException();
}
commandLine.emptyCheck();
}
/*
......
......@@ -47,8 +47,11 @@ public:
*/
QStringList args();
void emptyCheck();
private:
QStringList m_commands; /* the command line list */
QStringList m_requested;
int m_index; /* current position in the list */
};
......
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