[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [5108] Refactor for simplicity
From: |
Greg Chicares |
Subject: |
[lmi-commits] [5108] Refactor for simplicity |
Date: |
Thu, 23 Sep 2010 00:52:36 +0000 |
Revision: 5108
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5108
Author: chicares
Date: 2010-09-23 00:52:36 +0000 (Thu, 23 Sep 2010)
Log Message:
-----------
Refactor for simplicity
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/main_cli.cpp
lmi/trunk/workhorse.make
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-09-23 00:20:42 UTC (rev 5107)
+++ lmi/trunk/ChangeLog 2010-09-23 00:52:36 UTC (rev 5108)
@@ -26809,3 +26809,9 @@
version.hpp
Designate release candidate.
+20100923T0052Z <address@hidden> [656]
+
+ main_cli.cpp
+ workhorse.make
+Refactor for simplicity.
+
Modified: lmi/trunk/main_cli.cpp
===================================================================
--- lmi/trunk/main_cli.cpp 2010-09-23 00:20:42 UTC (rev 5107)
+++ lmi/trunk/main_cli.cpp 2010-09-23 00:52:36 UTC (rev 5108)
@@ -50,11 +50,13 @@
#include "value_cast.hpp"
#include <boost/bind.hpp>
+#include <boost/filesystem/convenience.hpp>
+#include <boost/filesystem/path.hpp>
#include <algorithm>
#include <cmath>
#include <cstddef> // NULL, std::size_t
-#include <cstdio> // std::printf(), std::remove()
+#include <cstdio> // std::printf()
#include <ios>
#include <iostream>
#include <iterator>
@@ -157,9 +159,6 @@
void process_command_line(int argc, char* argv[])
{
// TRICKY !! Some long options are aliased to unlikely octal values.
-// static char const* vfile[] = {"file", "archive", 0};
-// static char const* vlist[] = {"one", "two", "three", 0};
-// static char const* vopt[] = {"optional", "alternative", 0};
static Option long_options[] =
{
{"ash_nazg" ,NO_ARG ,0 ,001 ,0 ,"ash nazg durbatul\xFBk"},
@@ -173,13 +172,9 @@
{"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"},
- {"illfile" ,REQD_ARG ,0 ,'i' ,0 ,"run illustration"},
- {"inifile" ,REQD_ARG ,0 ,'n' ,0 ,"run custom .ini file"},
- {"cnsfile" ,REQD_ARG ,0 ,'c' ,0 ,"run census"},
-// {"gptfile" ,REQD_ARG ,0 ,'g' ,0 ,"test GPT"}, // Reserved for future
use.
- {"mecfile" ,REQD_ARG ,0 ,'m' ,0 ,"test MEC testing"},
+ {"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"},
+ {"print_db" ,NO_ARG ,0 ,'p' ,0 ,"print product databases and exit"},
{0 ,NO_ARG ,0 ,0 ,0 ,""}
};
@@ -189,20 +184,14 @@
bool run_selftest = false;
bool run_profile = false;
bool print_all_databases = false;
- bool run_illustration = false;
- bool run_ini = false;
- bool run_census = false;
- bool run_mec_test = false;
e_emission emission(mce_emit_nothing);
// Suppress enumerators for options not fully implemented.
emission.allow(emission.ordinal("emit_pdf_to_printer"), false);
emission.allow(emission.ordinal("emit_pdf_to_viewer" ), false);
- std::vector<std::string> ill_names;
- std::vector<std::string> ini_names;
- std::vector<std::string> cns_names;
- std::vector<std::string> mec_names;
+ std::vector<std::string> illustrator_names;
+ std::vector<std::string> mec_server_names;
int digit_optind = 0;
int this_option_optind = 1;
@@ -277,13 +266,6 @@
}
break;
- case 'c':
- {
- run_census = true;
- cns_names.push_back(getopt_long.optarg);
- }
- break;
-
case 'd':
{
global_settings::instance().set_data_directory
@@ -329,18 +311,34 @@
}
break;
-// case 'g': // Reserved for future use.
-
- case 'h':
+ case 'f':
{
- show_help = true;
+ LMI_ASSERT(NULL != getopt_long.optarg);
+ std::string const s(getopt_long.optarg);
+ std::string const e = fs::extension(s);
+ if(".cns" == e || ".ill" == e || ".ini" == e)
+ {
+ illustrator_names.push_back(getopt_long.optarg);
+ }
+ else if(".mec" == e)
+ {
+ mec_server_names.push_back(getopt_long.optarg);
+ }
+ else
+ {
+ warning()
+ << "'"
+ << s
+ << "': unrecognized file extension."
+ << LMI_FLUSH
+ ;
+ }
}
break;
- case 'i':
+ case 'h':
{
- run_illustration = true;
- ill_names.push_back(getopt_long.optarg);
+ show_help = true;
}
break;
@@ -350,20 +348,6 @@
}
break;
- case 'm':
- {
- run_mec_test = true;
- mec_names.push_back(getopt_long.optarg);
- }
- break;
-
- case 'n':
- {
- run_ini = true;
- ini_names.push_back(getopt_long.optarg);
- }
- break;
-
case 'o':
{
run_profile = true;
@@ -428,7 +412,6 @@
if(show_help)
{
getopt_long.usage();
-
std::cout << "Suboptions for '--emit':\n";
for(std::size_t j = 0; j < emission.cardinality(); ++j)
{
@@ -437,7 +420,6 @@
std::cout << " " << emission.str(j) << '\n';
}
}
-
return;
}
@@ -459,41 +441,17 @@
return;
}
- if(run_illustration)
- {
- std::for_each
- (ill_names.begin()
- ,ill_names.end()
- ,illustrator(emission.value())
- );
- }
+ std::for_each
+ (illustrator_names.begin()
+ ,illustrator_names.end()
+ ,illustrator(emission.value())
+ );
- if(run_ini)
- {
- std::for_each
- (ini_names.begin()
- ,ini_names.end()
- ,illustrator(emission.value())
- );
- }
-
- if(run_census)
- {
- std::for_each
- (cns_names.begin()
- ,cns_names.end()
- ,illustrator(emission.value())
- );
- }
-
- if(run_mec_test)
- {
- std::for_each
- (mec_names.begin()
- ,mec_names.end()
- ,mec_server(emission.value())
- );
- }
+ std::for_each
+ (mec_server_names.begin()
+ ,mec_server_names.end()
+ ,mec_server(emission.value())
+ );
}
int try_main(int argc, char* argv[])
Modified: lmi/trunk/workhorse.make
===================================================================
--- lmi/trunk/workhorse.make 2010-09-23 00:20:42 UTC (rev 5107)
+++ lmi/trunk/workhorse.make 2010-09-23 00:52:36 UTC (rev 5108)
@@ -1138,13 +1138,13 @@
--accept \
--data_path=$(data_dir) \
--emit=$(special_emission),emit_text_stream,emit_quietly,emit_timings
\
- $(file_option)=$* \
+ --file=$* \
| $(SED) -e '/milliseconds/!d'
@./lmi_cli_shared$(EXEEXT) \
--accept \
--data_path=$(data_dir) \
--emit=$(special_emission),emit_text_stream,emit_quietly \
- $(file_option)=$* \
+ --file=$* \
>$*.touchstone
@<$*.touchstone \
$(DIFF) \
@@ -1208,11 +1208,6 @@
system_test_diffs := $(test_dir)/diffs-$(yyyymmddhhmm)
system_test_md5sums := $(test_dir)/md5sums-$(yyyymmddhhmm)
-%.cns: file_option := --cnsfile
-%.ill: file_option := --illfile
-%.ini: file_option := --inifile
-%.mec: file_option := --mecfile
-
%.cns: test_emission := emit_quietly,emit_test_data
%.ill: test_emission := emit_quietly,emit_test_data
%.ini: test_emission := emit_quietly,emit_custom_0
@@ -1244,7 +1239,7 @@
--data_path=$(data_dir) \
--emit=$(test_emission) \
--pyx=system_testing \
- $(file_option)=$@
+ --file=$@
@$(MD5SUM) $(basename $(notdir $@)).* >> $(system_test_md5sums)
@for z in $(dot_test_files); \
do \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [5108] Refactor for simplicity,
Greg Chicares <=