From aa2cee16810277212dd8e9354a63cfe572207158 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 20 Jun 2011 17:10:11 +0200 Subject: started command line parsing.. --- run.sh | 3 ++- src/main.cpp | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index 1c3d15f..3baee26 100755 --- a/run.sh +++ b/run.sh @@ -1,5 +1,6 @@ #!/bin/bash -# set your QT version here +# All args are passed to fbsplash. +# Set your QT version here QT_VERSION=4.7.2 # qvfb's width diff --git a/src/main.cpp b/src/main.cpp index fd171ce..cd1f5e0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,13 +1,42 @@ #include +#include #include "fbsplash.h" +void printHelp(){ + QTextStream qout(stdout); + qout << "Usage: ./fbsplash [OPTIONS]\n"; + qout << "Options:\n"; + qout << "-h, --help " << "Prints this help.\n"; + qout.flush(); + exit(EXIT_SUCCESS); +} + int main(int argc, char *argv[]) { QApplication app(argc, argv, QApplication::GuiServer); app.setOrganizationName("OpenSLX"); app.setApplicationName("fbsplash"); - fbsplash bs; + // Command line arguements parsing + QMap clOpts; + int longIndex = 0; + static const char *optString = "c:u:d:s:t:D:hl:"; + static const struct option longOpts[] = { { "help", no_argument, NULL, 'h' } }; + int opt = getopt_long(argc, argv, optString, longOpts, &longIndex); + while (opt != -1) { + switch (opt) { + case 'h': + clOpts.insert("help", "help"); + break; + } + opt = getopt_long(argc, argv, optString, longOpts, &longIndex); + } + if (clOpts.contains("help")) + printHelp(); + + + // fbsplash init + fbsplash bs; app.exec(); } -- cgit v1.2.3-55-g7522