25 #include <utils/system/argparser.h> 26 #include "plugin_generator.h" 32 print_usage(
const char *program_name)
34 printf(
"Usage: %s [-h] <author_name> <plugin_name> <description> <directory> \n" 35 "Example: %s \"John Doe\" robot_mover \"Move the robot a meter forward\" \n" 36 " ~/fawkes/src/plugins/robot_mover/" 38 "-h Print this usage information\n\n" 39 "Generate the necessary files to build a fawkes plugin\n",
40 program_name, program_name);
44 generate_plugin(std::string author_name, std::string plugin_name, std::string description, std::string directory)
47 std::string date = ctime(&now);
48 tm *time_structure = localtime(&now);
49 std::string year = std::to_string(time_structure->tm_year + 1900);
57 plugin_name_valid(std::string plugin_name){
58 for (
char& c : plugin_name){
59 if (isalpha(c) || c ==
'-' || c ==
'_') {
68 main(
int argc,
char **argv)
72 if ( argp.has_arg(
"h") ) {
77 std::string author_name, plugin_name, description, directory;
78 if (argp.num_items() != 4) {
79 printf(
"ERROR: Invalid number of arguments\n");
82 }
else if (!plugin_name_valid(argp.items()[1])) {
83 printf(
"ERROR: Invalid plugin name: Only alphanumerical chars allowed. \n" 84 "To separate multiple words use '-' or '_'\n");
88 author_name = argp.items()[0];
89 plugin_name = argp.items()[1];
90 description = argp.items()[2];
91 directory = argp.items()[3];
92 generate_plugin(author_name, plugin_name, description, directory);
Fawkes library namespace.
Parse command line arguments.
void generate()
Generator cpp and h files.
Generate basic plugins from minimal input.