lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 5477797 3/7: Add '--prospicience' command-lin


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 5477797 3/7: Add '--prospicience' command-line argument for CLI binary
Date: Mon, 4 Mar 2019 12:06:41 -0500 (EST)

branch: master
commit 547779753682a15e382e080d434aa76553e1c5d8
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Add '--prospicience' command-line argument for CLI binary
    
    Copied code from 'skeleton.cpp' GUI driver into CLI driver. This option
    is as needful for CLI as for GUI binaries: even though CLI binaries
    don't call authenticate_system() at startup, they do call it for these
    emission types:
        mce_emit_spreadsheet
        mce_emit_group_roster
    in order to enforce the strong invariant that illustrations cannot be
    produced without prior authentication.
---
 main_cli.cpp | 54 +++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 39 insertions(+), 15 deletions(-)

diff --git a/main_cli.cpp b/main_cli.cpp
index d207bd4..c9feadf 100644
--- a/main_cli.cpp
+++ b/main_cli.cpp
@@ -23,6 +23,7 @@
 
 #include "alert.hpp"
 #include "assert_lmi.hpp"
+#include "calendar_date.hpp"
 #include "contains.hpp"
 #include "dbdict.hpp"                   // print_databases()
 #include "getopt.hpp"
@@ -160,21 +161,22 @@ void process_command_line(int argc, char* argv[])
     // TRICKY !! Some long options are aliased to unlikely octal values.
     static Option long_options[] =
       {
-        {"ash_nazg"  ,NO_ARG   ,0 ,001 ,0 ,"ash nazg durbatulûk"},
-        {"ash_naz"   ,NO_ARG   ,0 ,003 ,0 ,"fraud"},
-        {"mellon"    ,NO_ARG   ,0 ,002 ,0 ,"pedo mellon a minno"},
-        {"mello"     ,NO_ARG   ,0 ,003 ,0 ,"fraud"},
-        {"pyx"       ,REQD_ARG ,0 ,'x' ,0 ,"for docimasy"},
-        {"help"      ,NO_ARG   ,0 ,'h' ,0 ,"display this help and exit"},
-        {"license"   ,NO_ARG   ,0 ,'l' ,0 ,"display license and exit"},
-        {"accept"    ,NO_ARG   ,0 ,'a' ,0 ,"accept license (-l to display)"},
-        {"selftest"  ,NO_ARG   ,0 ,'s' ,0 ,"perform self test and exit"},
-        {"profile"   ,NO_ARG   ,0 ,'o' ,0 ,"set up for profiling and exit"},
-        {"emit"      ,REQD_ARG ,0 ,'e' ,0 ,"choose what output to emit"},
-        {"file"      ,REQD_ARG ,0 ,'f' ,0 ,"input file to run"},
-        {"data_path" ,REQD_ARG ,0 ,'d' ,0 ,"path to data files"},
-        {"print_db"  ,NO_ARG   ,0 ,'p' ,0 ,"print product databases and exit"},
-        {0           ,NO_ARG   ,0 ,0   ,0 ,""}
+        {"ash_nazg"     ,NO_ARG   ,0 ,001 ,0 ,"ash nazg durbatulûk"},
+        {"ash_naz"      ,NO_ARG   ,0 ,003 ,0 ,"fraud"},
+        {"mellon"       ,NO_ARG   ,0 ,002 ,0 ,"pedo mellon a minno"},
+        {"mello"        ,NO_ARG   ,0 ,003 ,0 ,"fraud"},
+        {"pyx"          ,REQD_ARG ,0 ,'x' ,0 ,"for docimasy"},
+        {"help"         ,NO_ARG   ,0 ,'h' ,0 ,"display this help and exit"},
+        {"license"      ,NO_ARG   ,0 ,'l' ,0 ,"display license and exit"},
+        {"accept"       ,NO_ARG   ,0 ,'a' ,0 ,"accept license (-l to 
display)"},
+        {"selftest"     ,NO_ARG   ,0 ,'s' ,0 ,"perform self test and exit"},
+        {"profile"      ,NO_ARG   ,0 ,'o' ,0 ,"set up for profiling and exit"},
+        {"emit"         ,REQD_ARG ,0 ,'e' ,0 ,"choose what output to emit"},
+        {"file"         ,REQD_ARG ,0 ,'f' ,0 ,"input file to run"},
+        {"data_path"    ,REQD_ARG ,0 ,'d' ,0 ,"path to data files"},
+        {"print_db"     ,NO_ARG   ,0 ,'p' ,0 ,"print product databases and 
exit"},
+        {"prospicience" ,REQD_ARG ,0 ,004 ,0 ,"validation date"},
+        {0              ,NO_ARG   ,0 ,0   ,0 ,""}
       };
 
     bool license_accepted    = false;
@@ -231,6 +233,28 @@ void process_command_line(int argc, char* argv[])
                 }
                 break;
 
+            case 004:
+                {
+                std::istringstream iss(getopt_long.optarg);
+                int ymd_as_int;
+                iss >> ymd_as_int;
+                if(!iss || !iss.eof())
+                    {
+                    warning() << "Invalid prospicience option value '"
+                              << getopt_long.optarg
+                              << "' (must be in YYYYMMDD format)."
+                              << std::flush
+                              ;
+                    }
+                else
+                    {
+                    global_settings::instance().set_prospicience_date
+                        (calendar_date(ymd_t(ymd_as_int))
+                        );
+                    }
+                }
+                break;
+
             case '0':
             case '1':
             case '2':



reply via email to

[Prev in Thread] Current Thread [Next in Thread]