[Genabel-commits] r1247 - pkg/ProbABEL/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 13 20:41:09 CEST 2013


Author: lckarssen
Date: 2013-06-13 20:41:09 +0200 (Thu, 13 Jun 2013)
New Revision: 1247

Modified:
   pkg/ProbABEL/src/command_line_settings.cpp
   pkg/ProbABEL/src/usage.cpp
   pkg/ProbABEL/src/usage.h
Log:
Don't print the entire option list when a required command line option is missing. Ask the user to use --help for that. 
- in usage.h/usage.cpp: put the printing of version information in a separate function, so we can call it both when things go well and when options are missing.
- command_line_settings.cpp: use the print_version function and print a friendly message when an option is missing.  Also some slight reformatting of the help output. 


Modified: pkg/ProbABEL/src/command_line_settings.cpp
===================================================================
--- pkg/ProbABEL/src/command_line_settings.cpp	2013-06-13 18:35:45 UTC (rev 1246)
+++ pkg/ProbABEL/src/command_line_settings.cpp	2013-06-13 18:41:09 UTC (rev 1247)
@@ -243,19 +243,10 @@
 
 void cmdvars::printinfo()
 {
-    cout << PACKAGE
-         << " v. " << PACKAGE_VERSION
-         << "\n(C) Yurii Aulchenko, Lennart C. Karssen, Maksim Struchalin, "
-         << "EMCR\n\n";
-#if EIGEN
-    cout << "Using EIGEN version " << EIGEN_WORLD_VERSION
-         << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION
-         << " for matrix operations\n";
-#endif
+    print_version();
 
     if (neco[0] != 1 || neco[1] != 1 || neco[2] != 1)
     {
-        cerr << endl;
         if (neco[0] != 1)
         {
             cerr << "Error: Missing required phenotype file (-p/--pheno option)"
@@ -272,9 +263,15 @@
                  << endl;
         }
         cerr << endl;
-        print_usage(program_name, 1);
+//        print_usage(program_name, 1);
+        cout << "One or more required command line options appear to be missing."
+             << endl
+             << "Run " << program_name
+             << " --help for more information on the available options\n";
+        exit(3);
     }
 
+
     if (score)
     {
         cout << "option --score suppressed from v 0.1-6\n";
@@ -288,20 +285,20 @@
         isFVF = 1;
 
     cout << "Options in effect:\n";
-    cout << "\t --pheno   = "          << phefilename << endl;
-    cout << "\t --info    = "          << mlinfofilename << endl;
-    cout << "\t --dose    = "          << genfilename << endl;
+    cout << "\t --pheno       = "      << phefilename << endl;
+    cout << "\t --info        = "      << mlinfofilename << endl;
+    cout << "\t --dose        = "      << genfilename << endl;
     if (isFVF)
         cout << "\t             (using FVF data)" << endl;
-    cout << "\t --ntraits = "          << noutcomes << endl;
-    cout << "\t --ngpreds = "          << ngpreds << endl;
+    cout << "\t --ntraits     = "      << noutcomes << endl;
+    cout << "\t --ngpreds     = "      << ngpreds << endl;
     cout << "\t --interaction = "      << interaction << endl;
     cout << "\t --interaction_only = " << interaction_excluded << endl;
 
     if (inverse_filename != NULL)
         cout << "\t --mmscore = "      << inverse_filename << endl;
     else
-        cout << "\t --mmscore     = not in output" << endl;
+        cout << "\t --mmscore = not in output" << endl;
 
     if (mapfilename != NULL)
         cout << "\t --map     = "      <<  mapfilename << endl;

Modified: pkg/ProbABEL/src/usage.cpp
===================================================================
--- pkg/ProbABEL/src/usage.cpp	2013-06-13 18:35:45 UTC (rev 1246)
+++ pkg/ProbABEL/src/usage.cpp	2013-06-13 18:41:09 UTC (rev 1247)
@@ -2,12 +2,22 @@
 #include <fstream>
 #include <cstdlib>
 #include <cstdio>
+#include "command_line_settings.h"
 
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if EIGEN
+#include "eigen_mematrix.h"
+#endif
+
+
 using namespace std;
 
 void print_usage(char * program_name, int exit_code)
 {
-    cout << "Usage: " << program_name << " options" << endl;
+    cout << "\nUsage: " << program_name << " options" << endl;
     cout << "Options:" << endl;
     cout << "\t --pheno   : phenotype file name" << endl;
     cout << "\t --info    : information (e.g. MLINFO) file name" << endl;
@@ -57,7 +67,22 @@
     exit(exit_code);
 }
 
+
+void print_version(void){
+    cout << PACKAGE
+         << " v. " << PACKAGE_VERSION
+         << "\n(C) Yurii Aulchenko, Lennart C. Karssen, Maksim Struchalin, "
+         << "EMCR\n\n";
+#if EIGEN
+    cout << "Using EIGEN version " << EIGEN_WORLD_VERSION
+         << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION
+         << " for matrix operations\n";
+#endif
+}
+
+
 void print_help(char * program_name, int exit_code)
 {
+    print_version();
     print_usage(program_name, exit_code);
 }

Modified: pkg/ProbABEL/src/usage.h
===================================================================
--- pkg/ProbABEL/src/usage.h	2013-06-13 18:35:45 UTC (rev 1246)
+++ pkg/ProbABEL/src/usage.h	2013-06-13 18:41:09 UTC (rev 1247)
@@ -11,4 +11,6 @@
 
 void print_help(char * program_name, int exit_code);
 
+void print_version(void);
+
 #endif /* USAGE_H_ */



More information about the Genabel-commits mailing list