Commit 93cbb2fc authored by Fabian Kosmale's avatar Fabian Kosmale

use QCoreApplication::arguments instead of argc and argv

parent fdfa265a
......@@ -12,8 +12,8 @@
#include <akabeiparser.h>
AkabeiParser::AkabeiParser(int argc, char **argv, const AkabeiAboutData& about)
: CommandLineParser(argc, argv, about)
AkabeiParser::AkabeiParser(const QStringList &args, const AkabeiAboutData& about)
: CommandLineParser(args, about)
{
/* Special operations */
AkabeiOperation help(APM::NoType, APM::Help, "", "help", QObject::tr("Show a help message"));
......@@ -224,4 +224,4 @@ QHash<APM::OptionName, QStringList> AkabeiParser::options()
QStringList AkabeiParser::args()
{
return m_args;
}
\ No newline at end of file
}
......@@ -22,7 +22,7 @@
class AkabeiParser : public CommandLineParser
{
public:
AkabeiParser(int, char**, const AkabeiAboutData &);
AkabeiParser(const QStringList &, const AkabeiAboutData &);
void addOperation(AkabeiOperation &);
void addOption(APM::OptionName name, QString const& cmdShort, QString const& cmdLong, QString const& desc, QString const& argname = QString());
......@@ -48,4 +48,4 @@ private:
void doParse();
};
#endif
\ No newline at end of file
#endif
......@@ -373,7 +373,8 @@ int main(int argc, char **argv)
CommandLineParser *parser = NULL;
QTextStream err(stderr);
QString arg0(argv[0]);
QStringList args = QCoreApplication::arguments();
QString arg0(args.takeFirst());
/*
* Takes program name if the user called something like /usr/bin/akabei
......@@ -383,11 +384,11 @@ int main(int argc, char **argv)
/* Inits the right parser for the program invoked */
if (arg0 == "akabei") {
parser = new AkabeiParser(argc, argv, aboutData);
parser = new AkabeiParser(args, aboutData);
initOptions(parser, true);
initAkabeiOperations(parser);
} else if (arg0 == "pakabei") {
parser = new PakabeiParser(argc, argv, aboutData);
parser = new PakabeiParser(args, aboutData);
initOptions(parser, false);
initPakabeiOperations(parser);
} else {
......
......@@ -101,8 +101,8 @@ void CommandLine::emptyCheck()
/*
* Build our database of accepted operations and options with the right properties and associations
*/
PakabeiParser::PakabeiParser(int argc, char **argv, const AkabeiAboutData& about)
: CommandLineParser(argc, argv, about)
PakabeiParser::PakabeiParser(const QStringList& args, const AkabeiAboutData& about)
: CommandLineParser(args, about)
{
typechars.insert("Q", APM::QueryOperationType);
typechars.insert("R", APM::RemoveOperationType);
......
......@@ -81,7 +81,7 @@ private:
bool areArgsRequired();
public:
PakabeiParser(int argc, char **argv, const AkabeiAboutData &);
PakabeiParser(const QStringList &, const AkabeiAboutData &);
void addOperation(AkabeiOperation &);
void addOption(APM::OptionName name, QString const& cmdShort, QString const& cmdLong, QString const& desc, QString const& argname = QString());
......
......@@ -12,13 +12,12 @@
#include <parser.h>
CommandLineParser::CommandLineParser(int argc, char **argv, const AkabeiAboutData& data)
CommandLineParser::CommandLineParser(const QStringList& args, const AkabeiAboutData& data)
: m_data(data)
{
QStringList optionWithArg;
for (int i = 1; i < argc; i++) {
QString arg( argv[i] );
foreach (QString const & arg, args) {
/* A long option is split from the argument, if present after a =, and then both are saved */
if (arg.startsWith("--") && arg.size() > 2) {
......
......@@ -28,12 +28,11 @@ public:
/**
* Constructs a new object and stores the argv in a more manageable format
* @param argc the command line arguments counter
* @param argv the command line arguments array
* @param args the command line arguments
* @param data some information about the program
* @throws CommandParsingException if some option is repeated twice (currently not allowed).
*/
CommandLineParser(int, char **, const AkabeiAboutData&);
CommandLineParser(const QStringList& args, const AkabeiAboutData& data);
virtual ~CommandLineParser() {}
/**
......@@ -109,4 +108,4 @@ public:
static void printLicenses(AkabeiAboutData &);
};
#endif
\ No newline at end of file
#endif
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