Skip to content

Commit 359dc84

Browse files
committed
Fix: Error when no params Available
Change: ArgV to QStringList
1 parent cef06fb commit 359dc84

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

Diff for: fusioncli.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ FusionCLI::FusionCLI(QObject *parent) : QObject(parent)
1010
}
1111

1212

13-
void FusionCLI::execute(int argc, char *argv[]) {
13+
void FusionCLI::execute(int argc, QStringList args) {
1414

15-
if(argc>1)
15+
if(argc>1)
1616
{
17-
QString arg = argv[1];
17+
QString arg = args[1];
1818
if(arg=="-g"||arg=="--allGames")
1919
getAllGames();
2020
else if(arg=="-r"||arg=="--refresh")
2121
refreshList();
2222
else if(arg=="-l"||arg=="--launch")
23-
launchByID(QString(argv[2]));
23+
launchByID(args[2]);
2424
else if(arg=="-i"||arg=="--gameInfo") {
25-
getGameByID(QString(argv[2]));
25+
getGameByID(args[2]);
2626
}
2727
}
2828
}

Diff for: fusioncli.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class FusionCLI : public QObject
1515
Q_OBJECT
1616
public:
1717
explicit FusionCLI(QObject *parent = 0);
18-
void execute(int argc, char *argv[]);
18+
void execute(int argc, QStringList args);
1919
void refreshList();
2020
void launchByID(QString ID);
2121
signals:

Diff for: main.cpp

+16-15
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,30 @@ int main(int argc, char *argv[])
7474

7575
qDebug() << "Args " <<args;
7676

77-
78-
7977
if(argc<=1) {
80-
qout << "Fusion Commandline-Interface"<< endl <<endl;
81-
qout << "Usage: fusioncli [options]"<< endl;
82-
qout << "--allGames -g: Get all Games with all Info"<< endl<<endl;
78+
qout << "Fusion Commandline-Interface" << endl <<endl;
79+
qout << "Usage: fusioncli [options]" << endl;
80+
qout << "--allGames | -g : Get all Games with all Info" << endl;
81+
qout << "--refresh | -r : Refresh Infos from Database" << endl;
82+
qout << "--launch [ID] | -l [ID]: Launch Game with ID" << endl;
83+
qout << "--gameInfo [ID] | -i [ID]: Get info for Game-ID" << endl << endl;
84+
8385

8486
QTimer::singleShot(10, &a, SLOT(quit()));
8587
#ifdef DEBUG_TEST
8688
dbgFile.close();
8789
delete dbgStream;
8890
#endif
89-
}
90-
91-
FusionCLI cli;
92-
cli.execute(argc, argv);
91+
} else {
92+
FusionCLI cli;
93+
cli.execute(argc, args);
9394

94-
QTimer::singleShot(10, &a, SLOT(quit()));
95-
96-
#ifdef DEBUG_TEST
97-
dbgFile.close();
98-
delete dbgStream;
99-
#endif
95+
QTimer::singleShot(10, &a, SLOT(quit()));
10096

97+
#ifdef DEBUG_TEST
98+
dbgFile.close();
99+
delete dbgStream;
100+
#endif
101+
}
101102
return a.exec();
102103
}

0 commit comments

Comments
 (0)