add support for a help flag and print text mode error message for nonexisting file
This commit is contained in:
@ -14,13 +14,30 @@
|
||||
#include "lammpsgui.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
const char *infile = nullptr;
|
||||
if (argc > 1) infile = argv[1];
|
||||
if (argc > 1) {
|
||||
infile = argv[1];
|
||||
if ((strcmp(infile, "-help") == 0) || (strcmp(infile, "-h") == 0)) {
|
||||
printf("This is LAMMPS-GUI version " LAMMPS_GUI_VERSION
|
||||
" using Qt version " QT_VERSION_STR "\n");
|
||||
printf("Usage: %s [-h|-help|<inputfile>]\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
if (!QFileInfo::exists(infile)) {
|
||||
printf("Input file %s does not exist\n", infile);
|
||||
printf("Usage: %s [-h|-help|<inputfile>]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
LammpsGui w(nullptr, infile);
|
||||
w.show();
|
||||
|
||||
Reference in New Issue
Block a user