1+ #!/usr/bin/wsjcpp-safe-scripting
2+
3+ # log_info rootdir
4+ # log_info script_filename
5+
6+ make_dir "src"
7+
8+ var argument_processor_name
9+ set_value argument_processor_name arg1
10+ normalize_class_name argument_processor_name
11+ convert_CamelCase_to_snake_case argument_processor_name argument_processor_name
12+
13+ var class_name
14+ concat class_name "ArgumentProcessor" arg1
15+ normalize_class_name class_name
16+
17+ var base_filename
18+ convert_CamelCase_to_snake_case class_name base_filename
19+ # log_info base_filename
20+
21+ var filename_cpp
22+ concat filename_cpp "./src/" base_filename ".cpp"
23+
24+ var filename_h
25+ concat filename_h "./src/" base_filename ".h"
26+
27+ var ifndef_header
28+ set_value ifndef_header base_filename
29+ concat ifndef_header "_H"
30+
31+ to_upper_case ifndef_header
32+
33+ var content_header
34+ concat content_header "#ifndef " ifndef_header "
35+ #define " ifndef_header "
36+
37+ #include <wsjcpp_arguments.h>
38+
39+ class " class_name " : public WSJCppArgumentProcessor {
40+ public:
41+ " class_name "();
42+
43+ virtual bool applyParameterArgument(const std::string &sProgramName, const std::string &sArgumentName, const std::string &sValue);
44+ virtual bool applySingleArgument(const std::string &sProgramName, const std::string &sArgumentName);
45+ virtual int exec(const std::string &sProgramName, const std::vector<std::string> &vSubParams);
46+ };
47+
48+ #endif // " ifndef_header
49+
50+
51+ var content_source
52+ concat content_source "
53+ #include \"" base_filename ".h\"
54+ #include <wsjcpp_core.h>
55+
56+ // ---------------------------------------------------------------------
57+ // " class_name "
58+
59+ " class_name "::" class_name "()
60+ : WSJCppArgumentProcessor(\"" argument_processor_name "\", \"TODO description\") {
61+ TAG = \"" argument_processor_name "\";
62+ // registrySingleArgument(\"--single\", \"What exactly do this single param?\");
63+ // registryParameterArgument(\"-param\", \"What need this param?\");
64+ // registryExample(\"here example of command\");
65+ // registryProcessor(new ArgumentProcessorOtherProcessor());
66+ }
67+
68+ // ---------------------------------------------------------------------
69+
70+ bool " class_name "::applySingleArgument(const std::string &sProgramName, const std::string &sArgumentName) {
71+ WSJCppLog::err(TAG, \"Not implemented\");
72+ return false;
73+ }
74+
75+ // ---------------------------------------------------------------------
76+
77+ bool " class_name "::applyParameterArgument(
78+ const std::string &sProgramName,
79+ const std::string &sArgumentName,
80+ const std::string &sValue
81+ ) {
82+ WSJCppLog::err(TAG, \"Not implemented\");
83+ return false;
84+ }
85+
86+ // ---------------------------------------------------------------------
87+
88+ int " class_name "::exec(const std::string &sProgramName, const std::vector<std::string> &vSubParams) {
89+ WSJCppLog::err(TAG, \"Not implemented\");
90+ return -1;
91+ }
92+ "
93+
94+ var file_source
95+ concat file_source "src/" filename_cpp
96+
97+ write_file filename_h content_header
98+ write_file filename_cpp content_source
99+
100+ log_info "
101+ ======
102+ Generated class:
103+ - " class_name "
104+ Generated files:
105+ - " filename_h "
106+ - " filename_cpp "
107+ ======
108+ "
109+
110+ cmakelists_txt_append_wsjcpp filename_h
111+ cmakelists_txt_append_wsjcpp filename_cpp
0 commit comments