00001 #include "Sct/Version.h"
00002 #include <iostream>
00003 #include <cstring>
00004 using namespace Sct;
00005 using namespace std;
00006
00007
00008 void longVersion() {
00009 cout << "VersionString:" << VersionString << endl;
00010 cout << "MajorVersion: " << MajorVersion << " Minor Version: " << MinorVersion << " Modifier: " << VersionModifier << endl;
00011 cout << "Version: " << Version << endl;
00012 cout << "BuildSystem: " << BuildSystem << endl;
00013 cout << "BuildHost: " << BuildHost << endl;
00014 cout << "BuildDate: " << BuildDate << endl;
00015 cout << "RodDaq Version: " << RodDaqVersion << endl;
00016 cout << "CmtConfig: " << CmtConfig << endl;
00017 cout << "Dataflow Version: " << DataFlowVersion << endl;
00018 cout << "OnlineVersion : " << OnlineVersion << endl;
00019 cout << "RootVersion: " << RootVersion << endl;
00020 cout << "GccVersion: " << GccVersion << endl;
00021 }
00022
00023 void shortVersion() {
00024 cout << Version << VersionModifier << endl;
00025 }
00026
00027 void helpMessage() {
00028 cout << "Prints out version information about the SctRodDaq system." << endl << endl;
00029 cout << "Usage: SctRodDaqVersion <options>" << endl;
00030 cout << "Possible options are: " << endl;
00031 cout << "\t-h, --help\t\tPrint this help message" << endl;
00032 cout << "\t-l, --long\t\tPrint out all version information" << endl;
00033 cout << "\t-s, --short\t\tPrint out short version information" << endl;
00034 cout << endl << "If no option is given, the default is -s" << endl;
00035 }
00036
00037 void handleShortArg(char arg) {
00038 switch (arg) {
00039 case 'h':
00040 helpMessage();
00041 break;
00042 case 'l':
00043 longVersion();
00044 break;
00045 case 's':
00046 shortVersion();
00047 break;
00048 default:
00049 cout << "Argument -" << arg << " not recognized" << endl;
00050 }
00051 }
00052
00053 void handleLongArg(const char* arg) {
00054 if (strcmp(arg, "--help") == 0) return handleShortArg('h');
00055 if (strcmp(arg, "--long") == 0) return handleShortArg('l');
00056 if (strcmp(arg, "--short") == 0) return handleShortArg('s');
00057 cout << "Argument " << arg << " not recognized" << endl;
00058 helpMessage();
00059 }
00060
00061 void handleArg(const char* arg) {
00062 if (arg[0] != '-') {
00063 cout << "Argument " << arg << " not recognized" << endl;
00064 helpMessage();
00065 return;
00066 }
00067 if (strlen(arg) == 2) handleShortArg(arg[1]);
00068 else handleLongArg(arg);
00069 }
00070
00071 int main(int argc, char** argv) {
00072
00073 switch (argc) {
00074 case 1:
00075 shortVersion();
00076 break;
00077 case 2:
00078 handleArg(argv[1]);
00079 break;
00080 default:
00081 helpMessage();
00082 }
00083 return 0;
00084 }