//==========================================================================
// Processes the command line parsing result
-struct ProcessCmdLine
+struct WxProcessCmdLine
{
ProcessCmdLine() {}
void Process(wxCmdLineParser& parser);
//==========================================================================
//==========================================================================
-void ProcessCmdLine::Process(wxCmdLineParser& parser)
+void WxProcessCmdLine::Process(wxCmdLineParser& parser)
{
proceed = true;
if (parser.Found(_T("D")))
void OnInitCmdLine(wxCmdLineParser& parser);
bool OnCmdLineParsed(wxCmdLineParser& parser);
- ProcessCmdLine cmd;
+ WxProcessCmdLine cmd;
};
//==========================================================================
//==========================================================================
#include "bbtkInterpreter.h"
-//#include "bbtkWx.h"
-int main(int argc, char* argv[])
-{
- if (argc>2)
+// Processes the command line parsing result
+struct ProcessCmdLine
+{
+ ProcessCmdLine() {}
+ void Process(int argc_, char *argv_[]);
+ bool Found(std::string value);
+
+ int argc;
+ std::vector<std::string> argv;
+ bool console;
+ bool debug;
+ bool quiet;
+ bool help;
+ bool graphical_dialog;
+ bool text_dialog;
+ bool no_console;
+ bool proceed;
+ std::map<std::string,std::string> param_map;
+ std::vector<std::string> input_file;
+
+};
+
+bool ProcessCmdLine::Found(std::string value)
+{
+ bool result=false;
+ for (int i=1; i<argc; ++i)
+ {
+ if (value==argv[i])
+ {
+ result = true;
+ }
+ } // for
+ return result;
+}
+
+void ProcessCmdLine::Process(int argc_, char *argv_[])
+{
+ argc = argc_;
+ for (int i=0; i<argc; ++i)
{
- std::cout << "usage : "<<argv[0]<<" [filename]"<<std::endl;
- return 0;
+ argv.push_back(argv_[i]);
+ } // for
+
+//EED proceed = true;
+ if (Found("D"))
+ {
+ bbtk::StaticInitTime::PrintObjectListInfo = true;
}
+
+ debug = ( Found("d") );
+ quiet = ( Found("q") );
+ help = ( Found("h") );
+ graphical_dialog = ( Found("g") );
+ text_dialog = ( Found("t") );
+ no_console = ( Found("N") );
+
+ if (quiet) bbtk::MessageManager::SetMessageLevel("max",0);
+ if (debug) bbtk::MessageManager::SetMessageLevel("all",9);
+
+ // parse the arguments and consider those which contain a "="
+ // as set input commands, other as files
+//EED int pargc = parser.GetParamCount();
+ for (int i=1; i<argc; ++i)
+ {
+ std::string s = argv[i];
+ std::string::size_type pos = s.find_first_of("=");
+ if (std::string::npos != pos)
+ {
+ std::string left = s.substr(0,pos);
+ std::string right = s.substr(pos+1,s.size());
+ param_map[left]=right;
+ }
+ else
+ {
+ input_file.push_back(s);
+ }
+ }// for
+
+ bool usage = (help && (input_file.size()==0));
+ if (usage) {
+ std::cout << "BBI (The Black Box Interpreter) - bbtk "
+ << bbtk::GetVersion() << " - (c) Creatis 2007-2008"
+ << std::endl;
+//EED parser.Usage();
+ proceed = false;
+ }
+
+ console = ( Found("c") ||
+ ((input_file.size() == 0) &&
+ (!no_console) &&
+ (!usage) ) );
+
+}
+//==========================================================================
+
+
+
+int main(int argc, char* argv[])
+{
+//EED
+// if (argc>2)
+// {
+// std::cout << "usage : "<<argv[0]<<" [filename]"<<std::endl;
+// return 0;
+// }
std::cout << "BBI (Black Box Interpreter) - bbtk "
<< bbtk::GetVersion()<< " - (c) Creatis 2007"
bbtk::Interpreter::Pointer I = bbtk::Interpreter::New();
if (argc==1)
- {
- I->CommandLineInterpreter();
- }
- else
-
- {
- std::string f(argv[1]);
- I->InterpretFile(f);
- }
+ {
+ I->CommandLineInterpreter();
+ } else {
+
+ ProcessCmdLine cmd;
+ cmd.Process(argc,argv);
+ I->SetInputs(cmd.param_map);
+
+ std::string f(argv[1]);
+ I->InterpretFile(f);
+ }
// bbtk::Wx::LoopUntilAllWindowsClose();