43 }
catch (std::exception& e) {
46 return CBuild::ARG_TYPE::SIMPLE_ARG;
52 if (std::string(argv[ptr]) == std::string(
"-v")) {
55 }
else if (std::string(argv[ptr]) == std::string(
"--no-cli-out")) {
59 CBuild::print(std::string(
"Illegal output mode! - \"") + std::string(argv[ptr]) +
67 }
catch (std::exception& e) {
69 std::string(argv[ptr + 1]) +
70 std::string(
"\", old output mode is - \"") +
71 std::string(args->
get_ptr(
"out")->data) + std::string(
"\"!"),
74 return CBuild::ARG_TYPE::SIMPLE_ARG;
80 if (!(argc >= (ptr + 1))) {
88 for (std::string gen : gens) {
89 if (gen == std::string(argv[ptr + 1])) {
96 CBuild::print(std::string(
"Illegal or unregistered generator name! - \"") +
97 std::string(argv[ptr + 1]) + std::string(
"\""),
105 }
catch (std::exception& e) {
107 std::string(argv[ptr + 1]) +
108 std::string(
"\", old generator is - \"") +
109 std::string(args->
get_ptr(
"gen")->data) + std::string(
"\"!"),
112 return CBuild::ARG_TYPE::GENERATOR_ARG;
118 if (argc <= (ptr + 1)) {
120 CBuild::print(std::string(
"Usage: ") + std::string(argv[ptr]) +
121 std::string(
" <toolchain id>"),
127 std::string token = argv[ptr];
129 if (token == std::string(
"-b")) {
131 }
else if (token == std::string(
"-br")) {
133 }
else if (token == std::string(
"-r")) {
135 }
else if (token == std::string(
"-d")) {
137 }
else if (token == std::string(
"-c")) {
139 }
else if (token == std::string(
"-ld")) {
145 for (std::string tool : tools) {
146 if (tool == std::string(argv[ptr + 1])) {
151 if (*type ==
CBuild::BUILD && std::string(argv[ptr + 1]) == std::string(
"all")) {
157 CBuild::print(std::string(
"Illegal or unregistered toolchain name! - \"") +
158 std::string(argv[ptr + 1]) + std::string(
"\""),
160 CBuild::print(std::string(
"Usage: ") + std::string(argv[ptr]) +
161 std::string(
" <toolchain id>"),
168 }
catch (std::exception& e) {
170 std::string(
"Toolchain is already set! New toolchain - \"") +
171 std::string(argv[ptr + 1]) + std::string(
"\", old toolchain is - \"") +
172 std::string(args->
get_ptr(
"toolchain_id")->data) + std::string(
"\"!"),
176 return CBuild::ARG_TYPE::TOOLCHAIN_ARG;
182 if (!(argc > (ptr + 1))) {
188 std::string task = argv[ptr + 1];
193 for (std::string t : tasks) {
201 CBuild::print(std::string(
"Illegal or unregistered task name! - \"") +
202 std::string(argv[ptr + 1]) + std::string(
"\""),
210 }
catch (std::exception& e) {
212 std::string(argv[ptr + 1]) + std::string(
"\", old task is - \"") +
213 std::string(args->
get_ptr(
"task_id")->data) + std::string(
"\"!"),
218 return CBuild::ARG_TYPE::TASK_ARG;
227 if (!(argc > (ptr + 1))) {
229 CBuild::print(std::string(
"Usage: ") + std::string(argv[ptr]) + std::string(
" <argument>"),
234 if (std::string(argv[ptr]) == std::string(
"-pa")) {
237 }
catch (std::exception& e) {
241 }
else if (std::string(argv[ptr]) == std::string(
"-a")) {
244 }
catch (std::exception& e) {
252 return CBuild::ARG_TYPE::GENERICK_ARG;
259 }
catch (std::exception& e) {
261 return CBuild::ARG_TYPE::SIMPLE_ARG;
289 inc = h->data(args, argv, argc, ptr, &ret);
292 const std::string* task = keywords.get(argv[ptr]);
297 }
catch (std::exception& e) {
299 inc = CBuild::ARG_TYPE::SIMPLE_ARG;
302 CBuild::print(std::string(
"Illegal argument! - \"") + std::string(argv[ptr]) +
318 }
catch (std::exception& e) {
Main headers of CBuild core.
Simple map implementation with some stack operation added.
void push_back_check(lib::mapData< _K, _D > element)
Add data, but check if key exists, if exist - trow exception.
lib::mapData< _K, _D > * get_ptr(_K key)
Get reference to key and value of map.
Defines and registering for handlers for cli parser.
Custom implementation of map datatype.
std::vector< std::string > GetToolchainsList()
Get list of registered toolchains.
lib::map< std::string, std::string > GetKeywordsList()
Get list of all user registered keywords.
void init()
Internal init.
std::vector< std::string > GetGeneratorsList()
Get list of registered generators.
std::vector< std::string > GetTasksList()
Get list of registered tasks.
Filebuffer for CBuild ecosystem.
ARG_TYPE force_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
ARG_TYPE out_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
lib::map< std::string, handler > parsers_list
All handlers.
void void void print_verbose()
Enable verbose flag.
ARG_TYPE task_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
void print(std::string msg, color fg=CBuild::WHITE)
Print colored text to STDOUT.
ARG_TYPE arg_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
ARG_TYPE(*)(lib::map< std::string, std::string > *, char **, int, int, CBuild::RType *) handler
Handler for specific argument.
RType parse(lib::map< std::string, std::string > *args, int argc, char **argv)
Parse arguments.
@ REBUILD
Rebuild user executable.
@ ERROR
Some error occurred.
@ DEBUG
Build and run target in debug mode.
@ CLEAR
Clear build output and cache.
@ BUILD_RUN
Build and run target.
@ LOAD_DEPS
Load other project deps.
ARG_TYPE
Type of argument, indicate how many tokens this argument consumes, including self.
void print_none()
Fully disable all print though CBuild::print.
ARG_TYPE rebuild_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
void print_full(std::string msg, color fg=CBuild::WHITE)
Print colored text to STDOUT if verbose flag is set.
ARG_TYPE generator_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
ARG_TYPE build_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
bool register_parse_handler(std::string cmd, CBuild::handler parser)
Register new handler for parsing cli args, see handler typedef comment to guide how to write handlers...
Custom print that support color codes.
Command for compile_commands.json.