[Fawkes Git] branch/jrothe/plugin_generator: created (0.5.0-3087-g02fbcd8)

Johannes Rothe johannes.rothe at rwth-aachen.de
Mon May 9 16:20:31 CEST 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, jrothe/plugin_generator has been created
        at  02fbcd8f2a846fc4a84416774290cb98849f7cf4 (commit)

http://git.fawkesrobotics.org/fawkes.git/jrothe/plugin_generator

- *Log* ---------------------------------------------------------------
commit b93909cd299e6adc64df5ac11ba46f34b759f6b9
Author:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
AuthorDate: Mon Apr 25 16:36:12 2016 +0200
Commit:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
CommitDate: Mon Apr 25 16:36:12 2016 +0200

    plugin_generator: new tool to autogenerate the plugin files
    
    With this tool you will be able to autogenerate all the
    necessary files and methods to build your own plugin.
    
    Detailed desciption and functionality will follow,
    in this version only the thread header and cpp
    files are generated.

http://git.fawkesrobotics.org/fawkes.git/commit/b93909c
http://trac.fawkesrobotics.org/changeset/b93909c

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit f258cb6ef63cac1855c35d51f4f1c16b0d5453b8
Author:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
AuthorDate: Mon May 2 13:53:33 2016 +0200
Commit:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
CommitDate: Mon May 2 13:53:33 2016 +0200

    plugin_generator: add method to generate plugin cpp

http://git.fawkesrobotics.org/fawkes.git/commit/f258cb6
http://trac.fawkesrobotics.org/changeset/f258cb6

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit e15601925acd43248c062a533b189b956383692b
Author:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
AuthorDate: Mon May 2 15:37:57 2016 +0200
Commit:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
CommitDate: Mon May 2 15:37:57 2016 +0200

    plugin_generator: add method to generate makefile

http://git.fawkesrobotics.org/fawkes.git/commit/e156019
http://trac.fawkesrobotics.org/changeset/e156019

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit d94736fb56c2df748be1662c225c285b854a565a
Author:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
AuthorDate: Mon May 2 15:57:46 2016 +0200
Commit:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
CommitDate: Mon May 2 15:57:46 2016 +0200

    plugin_generator: fixed missing semicolon
    
    The generated plugin is compiling

http://git.fawkesrobotics.org/fawkes.git/commit/d94736f
http://trac.fawkesrobotics.org/changeset/d94736f

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit d80479bf70741fa8b9a4652e6962df492f68d6d7
Author:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
AuthorDate: Mon May 9 16:17:16 2016 +0200
Commit:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
CommitDate: Mon May 9 16:17:16 2016 +0200

    plugin_generator: add check if dir is existing

http://git.fawkesrobotics.org/fawkes.git/commit/d80479b
http://trac.fawkesrobotics.org/changeset/d80479b

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 02fbcd8f2a846fc4a84416774290cb98849f7cf4
Author:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
AuthorDate: Mon May 9 16:19:24 2016 +0200
Commit:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
CommitDate: Mon May 9 16:19:24 2016 +0200

    plugin_generator: main method changed to working version

http://git.fawkesrobotics.org/fawkes.git/commit/02fbcd8
http://trac.fawkesrobotics.org/changeset/02fbcd8

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 src/tools/plugin_generator/main.cpp             |   63 ++++++++----
 src/tools/plugin_generator/plugin_generator.cpp |  131 +++++++++++++++++++---
 src/tools/plugin_generator/plugin_generator.h   |    2 +
 3 files changed, 159 insertions(+), 37 deletions(-)


- *Diffs* -------------------------------------------------------------

- *commit* b93909cd299e6adc64df5ac11ba46f34b759f6b9 - - - - - - - - - -
Author:  Johannes Rothe <johannes.rothe at rwth-aachen.de>
Date:    Mon Apr 25 16:36:12 2016 +0200
Subject: plugin_generator: new tool to autogenerate the plugin files

 src/tools/{watchdog => plugin_generator}/Makefile |   32 ++-
 src/tools/plugin_generator/main.cpp               |   64 +++++
 src/tools/plugin_generator/plugin_generator.cpp   |  274 +++++++++++++++++++++
 src/tools/plugin_generator/plugin_generator.h     |   66 +++++
 4 files changed, 423 insertions(+), 13 deletions(-)


- *commit* f258cb6ef63cac1855c35d51f4f1c16b0d5453b8 - - - - - - - - - -
Author:  Johannes Rothe <johannes.rothe at rwth-aachen.de>
Date:    Mon May 2 13:53:33 2016 +0200
Subject: plugin_generator: add method to generate plugin cpp

 src/tools/plugin_generator/plugin_generator.cpp |   45 +++++++++++++++++++++--
 src/tools/plugin_generator/plugin_generator.h   |    1 +
 2 files changed, 43 insertions(+), 3 deletions(-)

_Diff for modified files_:
diff --git a/src/tools/plugin_generator/plugin_generator.cpp b/src/tools/plugin_generator/plugin_generator.cpp
index 4cbd3f7..4e1378b 100644
--- a/src/tools/plugin_generator/plugin_generator.cpp
+++ b/src/tools/plugin_generator/plugin_generator.cpp
@@ -105,13 +105,13 @@ PluginGenerator::write_header(FILE *f, std::string filename)
 	  " *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
 	  " *  GNU Library General Public License for more details.\n"
 	  " *\n"
-	  " *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.\n"
+	  " *  Read the full text in the LICENSE.GPL file in the doc directory.\n"
 	  " */\n\n",
 	  filename.c_str(), _plugin_name.c_str(),
-	  (_creation_date.length() > 0 ) ? " *  Interface created: " : "",
+	  (_creation_date.length() > 0 ) ? " *  Plugin created: " : "",
 	  (_creation_date.length() > 0 ) ? _creation_date.c_str() : "",
 	  (_creation_date.length() > 0 ) ? "\n" : "",
-	  _year.c_str(), (_author.length() > 0) ? _author.c_str() : "AllemaniACs RoboCup Team"
+	  _year.c_str(),  _author.c_str()
 	  );
 }
 
@@ -199,6 +199,7 @@ PluginGenerator::write_thread_h(FILE *f)
           "  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */\n"
           "  protected: virtual void run() { Thread::run(); }\n\n"
           " private:\n"
+          "  //Define class member variables here\n"
           ,
 	  _class_name_thread.c_str(),
 	  _class_name_thread.c_str());
@@ -206,6 +207,43 @@ PluginGenerator::write_thread_h(FILE *f)
   fprintf(f, "\n};\n\n\n#endif");
 }
 
+void
+PluginGenerator::write_plugin_cpp(FILE *f)
+{
+  write_header(f, _filename_plugin_cpp);
+  fprintf(f,
+          "#include <core/plugin.h>\n\n"
+          "#include \"%s\"\n\n"
+          "using namespace fawkes;\n\n",
+          _filename_thread_h.c_str());
+  fprintf(f,
+          "/* @class %s \"%s\"\n"
+          " * %s\n"
+          " * @author %s\n"
+          " */\n",
+          _class_name_plugin.c_str(), _filename_plugin_cpp.c_str(),
+          _description.c_str(), _author.c_str());
+  fprintf(f,
+          "class %s : public fawkes::Plugin\n"
+          "{\n"
+          " public:\n"
+          "  /* Constructor\n"
+          "   * @param config Fakwes configuration\n"
+          "   */\n"
+          "  %s(Configuration *config)\n"
+          "     : Plugin(config)\n"
+          "  {\n"
+          "     thread_list.push_back(new %s();\n"
+          "  }\n"
+          "};\n\n",
+          _class_name_plugin.c_str(), _class_name_plugin.c_str(),
+          _class_name_thread.c_str());
+  fprintf(f,
+          "PLUGIN_DESCRIPTION(\"%s\")\n"
+          "EXPORT_PLUGIN(%s)",
+          _description.c_str(), _class_name_plugin.c_str());
+}
+
 /*
  * Format a lowercase plugin name to CamelCase plugin name and append
  * a string to specify the name
@@ -268,6 +306,7 @@ PluginGenerator::generate()
   
   write_thread_cpp(thread_cpp);
   write_thread_h(thread_h);
+  write_plugin_cpp(plugin_cpp);
 
   fclose(thread_cpp);
   fclose(thread_h);
diff --git a/src/tools/plugin_generator/plugin_generator.h b/src/tools/plugin_generator/plugin_generator.h
index 3e8fe23..3546d4d 100644
--- a/src/tools/plugin_generator/plugin_generator.h
+++ b/src/tools/plugin_generator/plugin_generator.h
@@ -40,6 +40,7 @@ class PluginGenerator
 
   void write_thread_h(FILE *f);
   void write_thread_cpp(FILE *f);
+  void write_plugin_cpp(FILE *f);
   void write_makefile(FILE *f);
   void write_header(FILE *f, std::string filename);
   void write_deflector(FILE *f);

- *commit* e15601925acd43248c062a533b189b956383692b - - - - - - - - - -
Author:  Johannes Rothe <johannes.rothe at rwth-aachen.de>
Date:    Mon May 2 15:37:57 2016 +0200
Subject: plugin_generator: add method to generate makefile

 src/tools/plugin_generator/main.cpp             |    4 +-
 src/tools/plugin_generator/plugin_generator.cpp |   53 ++++++++++++++++++++++-
 src/tools/plugin_generator/plugin_generator.h   |    1 +
 3 files changed, 55 insertions(+), 3 deletions(-)

_Diff for modified files_:
diff --git a/src/tools/plugin_generator/main.cpp b/src/tools/plugin_generator/main.cpp
index 1c624ad..1cac5d4 100644
--- a/src/tools/plugin_generator/main.cpp
+++ b/src/tools/plugin_generator/main.cpp
@@ -51,10 +51,10 @@ main(int argc, char **argv)
 int
 main()
 {
-  std::string dir = ".";
+  std::string dir = "../src/plugins/generator_test/" ; //TODO generate folder
   std::string author = "Johannes Rothe";
   std::string year = "2016";
-  std::string date = "25.04";
+  std::string date = "25.04.2016";
   std::string name = "generator_test";
   std::string description = "I am the description";
 
diff --git a/src/tools/plugin_generator/plugin_generator.cpp b/src/tools/plugin_generator/plugin_generator.cpp
index 4e1378b..9070d9f 100644
--- a/src/tools/plugin_generator/plugin_generator.cpp
+++ b/src/tools/plugin_generator/plugin_generator.cpp
@@ -64,6 +64,7 @@ PluginGenerator::PluginGenerator(std::string directory,
   _filename_thread_cpp = plugin_name + "_thread.cpp";
   _filename_thread_h   = plugin_name + "_thread.h";
   _filename_plugin_cpp = plugin_name + "_plugin.cpp";
+  _filename_makefile   = "Makefile";
 
   _plugin_name = plugin_name;
 
@@ -115,6 +116,27 @@ PluginGenerator::write_header(FILE *f, std::string filename)
 	  );
 }
 
+void
+PluginGenerator::write_makefile_header(FILE *f, std::string filename){
+  fprintf(f,
+          "#*****************************************************************************\n"
+          "#         Makefile Build System for Fawkes: %s Plugin\n"
+          "#                            -------------------\n"
+          "#   Created on %s \n"
+          "#   Copyright (C) %s by %s\n"
+          "#\n"
+          "#*****************************************************************************\n"
+          "#\n"
+          "#   This program is free software; you can redistribute it and/or modify\n"
+          "#   it under the terms of the GNU General Public License as published by\n"
+          "#   the Free Software Foundation; either version 2 of the License, or\n"
+          "#   (at your option) any later version.\n"
+          "#\n"
+          "#*****************************************************************************\n\n",
+          _plugin_name.c_str(), _creation_date.c_str(), _year.c_str(),
+          _author.c_str());
+}
+
 
 /** Write header deflector.
  * @param f file to write to
@@ -244,6 +266,28 @@ PluginGenerator::write_plugin_cpp(FILE *f)
           _description.c_str(), _class_name_plugin.c_str());
 }
 
+void
+PluginGenerator::write_makefile (FILE* f)
+{
+  write_makefile_header(f, _filename_makefile);
+  std::string filename_plugin_o = _plugin_name + "_plugin.o";
+  std::string filename_thread_o = _plugin_name + "_thread.o";
+  fprintf(f,
+          "BASEDIR = ../../..\n"
+          "include $(BASEDIR)/etc/buildsys/config.mk\n\n"
+          "LIBS_%s = m fawkescore fawkesutils fawkesaspects fawkesbaseapp \\\n"
+          "                      fawkesblackboard fawkesinterface\n\n"
+          "OBJS_%s = %s %s\n\n",
+          _plugin_name.c_str(), _plugin_name.c_str(), filename_plugin_o.c_str(),
+          filename_thread_o.c_str()
+          );
+  fprintf(f,
+         "PLUGINS_all = $(PLUGINDIR)/%s.$(SOEXT)\n\n"
+         "OBJS_all = $(OBJS_%s)\n\n"
+         "include $(BUILDSYSDIR)/base.mk",
+         _plugin_name.c_str(), _plugin_name.c_str());
+}
+
 /*
  * Format a lowercase plugin name to CamelCase plugin name and append
  * a string to specify the name
@@ -288,11 +332,12 @@ PluginGenerator::generate()
   FILE *thread_cpp;
   FILE *thread_h;
   FILE *plugin_cpp;
-  //TODO Makefile, Pluginfile
+  FILE *makefile;
 
   thread_h   = fopen(string(_dir + _filename_thread_h).c_str(), "w");
   thread_cpp = fopen(string(_dir + _filename_thread_cpp).c_str(), "w");
   plugin_cpp = fopen(string(_dir + _filename_plugin_cpp).c_str(), "w");
+  makefile   = fopen(string(_dir + _filename_makefile).c_str(), "w");
 
   if ( thread_h == NULL ) {
     printf("Cannot open thread_h file %s%s\n", _dir.c_str(), _filename_thread_h.c_str());
@@ -303,11 +348,17 @@ PluginGenerator::generate()
   if ( plugin_cpp == NULL ) {
     printf("Cannot open plugin_cpp file %s%s\n", _dir.c_str(), _filename_plugin_cpp.c_str());
   }
+  if ( makefile == NULL ) {
+    printf("Cannot open makefile %s%s\n", _dir.c_str(), _filename_makefile.c_str());
+  }
   
   write_thread_cpp(thread_cpp);
   write_thread_h(thread_h);
   write_plugin_cpp(plugin_cpp);
+  write_makefile(makefile);
 
   fclose(thread_cpp);
   fclose(thread_h);
+  fclose(plugin_cpp);
+  fclose(makefile);
 }
diff --git a/src/tools/plugin_generator/plugin_generator.h b/src/tools/plugin_generator/plugin_generator.h
index 3546d4d..f857c92 100644
--- a/src/tools/plugin_generator/plugin_generator.h
+++ b/src/tools/plugin_generator/plugin_generator.h
@@ -42,6 +42,7 @@ class PluginGenerator
   void write_thread_cpp(FILE *f);
   void write_plugin_cpp(FILE *f);
   void write_makefile(FILE *f);
+  void write_makefile_header(FILE *f, std::string filename);
   void write_header(FILE *f, std::string filename);
   void write_deflector(FILE *f);
   std::string format_class_name(std::string plugin_name, std::string append);

- *commit* d94736fb56c2df748be1662c225c285b854a565a - - - - - - - - - -
Author:  Johannes Rothe <johannes.rothe at rwth-aachen.de>
Date:    Mon May 2 15:57:46 2016 +0200
Subject: plugin_generator: fixed missing semicolon

 src/tools/plugin_generator/plugin_generator.cpp |   26 +++++++++-------------
 1 files changed, 11 insertions(+), 15 deletions(-)

_Diff for modified files_:
diff --git a/src/tools/plugin_generator/plugin_generator.cpp b/src/tools/plugin_generator/plugin_generator.cpp
index 9070d9f..130ea95 100644
--- a/src/tools/plugin_generator/plugin_generator.cpp
+++ b/src/tools/plugin_generator/plugin_generator.cpp
@@ -98,8 +98,7 @@ PluginGenerator::write_header(FILE *f, std::string filename)
 	  "/*  This program is free software; you can redistribute it and/or modify\n"
 	  " *  it under the terms of the GNU General Public License as published by\n"
 	  " *  the Free Software Foundation; either version 2 of the License, or\n"
-	  " *  (at your option) any later version. A runtime exception applies to\n"
-	  " *  this software (see LICENSE.GPL_WRE file mentioned below for details).\n"
+	  " *  (at your option) any later version.\n"
 	  " *\n"
 	  " *  This program is distributed in the hope that it will be useful,\n"
 	  " *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
@@ -158,7 +157,7 @@ PluginGenerator::write_thread_cpp(FILE *f)
   write_header(f, _filename_thread_cpp);
   fprintf(f,
           "#include \"%s\"\n\n"
-	  "using namespace fawkes \n\n"
+	  "using namespace fawkes;\n\n"
 	  "/** @class %s '%s' \n"
 	  " * %s\n"
 	  " * @author %s\n"
@@ -169,14 +168,10 @@ PluginGenerator::write_thread_cpp(FILE *f)
   //Constructor
   fprintf(f,
           "%s::%s()\n"
-          " : Thread(\"%s\", Thread::OPMODE_CONTINUOUS)\n{\n}\n\n", //TODO support the other OPMODES
+          " : Thread(\"%s\", Thread::OPMODE_WAITFORWAKEUP),\n"
+          "             BlockedTimingAspect(BlockedTimingAspect::WAKEUP_HOOK_SKILL) \n{\n}\n\n", //TODO support the other OPMODES
           _class_name_thread.c_str(), _class_name_thread.c_str(),
           _class_name_thread.c_str());
-  //Destructor
-  fprintf(f,
-          "%s::~%s()\n{\n}\n\n",
-          _class_name_thread.c_str(),
-          _class_name_thread.c_str());
   //init
   fprintf(f,
           "void\n%s::init()\n{\n}\n\n", _class_name_thread.c_str());
@@ -198,11 +193,12 @@ PluginGenerator::write_thread_h(FILE *f)
   write_deflector(f);
 
   fprintf(f,
-          "#include <string>\n"
           "#include <core/threading/thread.h>\n"
           "#include <aspect/blocked_timing.h>\n"
           "#include <aspect/logging.h>\n"
+          "#include <aspect/blackboard.h>\n"
           "#include <aspect/configurable.h>\n\n"
+          "#include <string>\n\n"
 
 	  "namespace fawkes {\n"
           "}\n\n"
@@ -214,10 +210,10 @@ PluginGenerator::write_thread_h(FILE *f)
           "  public fawkes::BlackBoardAspect\n"
 	  "{\n\n"
 	  " public:\n"
-          "  %s()\n\n"
-          "  virtual void init()\n"
-          "  virtual void finalize()\n"
-          "  virtual void loop()\n\n"
+          "  %s();\n\n"
+          "  virtual void init();\n"
+          "  virtual void finalize();\n"
+          "  virtual void loop();\n\n"
           "  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */\n"
           "  protected: virtual void run() { Thread::run(); }\n\n"
           " private:\n"
@@ -255,7 +251,7 @@ PluginGenerator::write_plugin_cpp(FILE *f)
           "  %s(Configuration *config)\n"
           "     : Plugin(config)\n"
           "  {\n"
-          "     thread_list.push_back(new %s();\n"
+          "     thread_list.push_back(new %s());\n"
           "  }\n"
           "};\n\n",
           _class_name_plugin.c_str(), _class_name_plugin.c_str(),

- *commit* d80479bf70741fa8b9a4652e6962df492f68d6d7 - - - - - - - - - -
Author:  Johannes Rothe <johannes.rothe at rwth-aachen.de>
Date:    Mon May 9 16:17:16 2016 +0200
Subject: plugin_generator: add check if dir is existing

 src/tools/plugin_generator/plugin_generator.cpp |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

_Diff for modified files_:
diff --git a/src/tools/plugin_generator/plugin_generator.cpp b/src/tools/plugin_generator/plugin_generator.cpp
index 130ea95..614993b 100644
--- a/src/tools/plugin_generator/plugin_generator.cpp
+++ b/src/tools/plugin_generator/plugin_generator.cpp
@@ -29,6 +29,7 @@
 #include <vector>
 #include <time.h>
 #include <fstream>
+#include <sys/stat.h>
 
 using namespace std;
 
@@ -330,6 +331,14 @@ PluginGenerator::generate()
   FILE *plugin_cpp;
   FILE *makefile;
 
+  struct stat info;
+
+  if (!(stat(_dir.c_str(), &info) == 0 && S_ISDIR(info.st_mode))) {
+      printf( "ERROR: Cannot open %s\n"
+          "Use this command to create it: \n"
+          "mkdir %s\n", _dir.c_str(), _dir.c_str());
+      exit(1);
+  }
   thread_h   = fopen(string(_dir + _filename_thread_h).c_str(), "w");
   thread_cpp = fopen(string(_dir + _filename_thread_cpp).c_str(), "w");
   plugin_cpp = fopen(string(_dir + _filename_plugin_cpp).c_str(), "w");

- *commit* 02fbcd8f2a846fc4a84416774290cb98849f7cf4 - - - - - - - - - -
Author:  Johannes Rothe <johannes.rothe at rwth-aachen.de>
Date:    Mon May 9 16:19:24 2016 +0200
Subject: plugin_generator: main method changed to working version

 src/tools/plugin_generator/main.cpp |   63 ++++++++++++++++++++++++----------
 1 files changed, 44 insertions(+), 19 deletions(-)

_Diff for modified files_:
diff --git a/src/tools/plugin_generator/main.cpp b/src/tools/plugin_generator/main.cpp
index 1cac5d4..b93fc8b 100644
--- a/src/tools/plugin_generator/main.cpp
+++ b/src/tools/plugin_generator/main.cpp
@@ -21,6 +21,7 @@
 
 #include <string>
 #include <cstdio>
+#include <ctime>
 #include <utils/system/argparser.h>
 #include "plugin_generator.h"
 
@@ -37,28 +38,52 @@ using namespace fawkes;
  * Maybe libraries to include in the Makefile and as includes
  */
 
-/*int
-main(int argc, char **argv)
+void
+print_usage(const char *program_name)
 {
-  ArgumentParser *argparser = new ArgumentParser(argc, argv, "hd:v");
-  const vector<const char *> & items = argparser->items();
-  if (items.size() == 0 || argparser->has_arg("h")) {
-      printf("Help stuff and binary description\n");
-  } else {
-    printf("Plugin Generator Starting\n");
-  }
-  */
+  printf("Usage: %s [-h] <author_name> <plugin_name> <description> <directory> \n"
+	 "Example: %s \"John Doe\" robot_mover \"Move the robot a meter forward\" \n"
+	 "                            ~/fawkes/src/plugins/robot_mover/"
+	 "\n"
+         "-h  Print this usage information\n\n"
+         "Generate the necessary files to build a fawkes plugin",
+	 program_name, program_name);
+}
+
+void
+generate_plugin(std::string author_name, std::string plugin_name, std::string description, std::string directory)
+{
+  time_t now = time(0);
+  std::string date = ctime(&now);
+  tm *time_structure = localtime(&now);
+  std::string year = std::to_string(time_structure->tm_year + 1900);
+
+  PluginGenerator *generator = new PluginGenerator(directory, author_name, year , date, plugin_name, description);
+  generator->generate();
+}
+
 int
-main()
+main(int argc, char **argv)
 {
-  std::string dir = "../src/plugins/generator_test/" ; //TODO generate folder
-  std::string author = "Johannes Rothe";
-  std::string year = "2016";
-  std::string date = "25.04.2016";
-  std::string name = "generator_test";
-  std::string description = "I am the description";
+  ArgumentParser argp(argc, argv, "h");
+
+  if ( argp.has_arg("h") ) {
+    print_usage(argv[0]);
+    exit(0);
+  }
 
-  PluginGenerator *generator = new PluginGenerator(dir, author, year, date, name, description);
+  std::string author_name, plugin_name, description, directory;
+  if (argp.num_items() != 4) {
+    printf("Invalid number of arguments\n");
+    print_usage(argv[0]);
+    exit(1);
+  } else {
+    author_name = argp.items()[0];
+    plugin_name = argp.items()[1];
+    description = argp.items()[2];
+    directory = argp.items()[3];
+    generate_plugin(author_name, plugin_name, description, directory);
+  }
 
-  generator->generate();
+  return 0;
 }




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list