22 #include "plugin_generator.h" 24 #include <utils/system/argparser.h> 34 print_usage(
const char *program_name)
36 printf(
"Usage: %s [-h] <author_name> <plugin_name> <description> <directory> \n" 37 "Example: %s \"John Doe\" robot_mover \"Move the robot a meter forward\" \n" 38 " ~/fawkes/src/plugins/robot_mover/" 40 "-h Print this usage information\n\n" 41 "Generate the necessary files to build a fawkes plugin\n",
47 generate_plugin(std::string author_name,
48 std::string plugin_name,
49 std::string description,
50 std::string directory)
53 std::string date = ctime(&now);
54 tm * time_structure = localtime(&now);
55 std::string year = std::to_string(time_structure->tm_year + 1900);
59 new PluginGenerator(directory, author_name, year, date, plugin_name, description);
64 plugin_name_valid(std::string plugin_name)
66 for (
char &c : plugin_name) {
67 if (!isalpha(c) && c !=
'-' && c !=
'_') {
75 main(
int argc,
char **argv)
79 if (argp.has_arg(
"h")) {
84 std::string author_name, plugin_name, description, directory;
85 if (argp.num_items() != 4) {
86 printf(
"ERROR: Invalid number of arguments\n");
89 }
else if (!plugin_name_valid(argp.items()[1])) {
90 printf(
"ERROR: Invalid plugin name: Only alphanumerical chars allowed. \n" 91 "To separate multiple words use '-' or '_'\n");
94 author_name = argp.items()[0];
95 plugin_name = argp.items()[1];
96 description = argp.items()[2];
97 directory = argp.items()[3];
98 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.