| 17 | // |
| 18 | |
| 19 | struct common_arg { |
| 20 | std::set<enum llama_example> examples = {LLAMA_EXAMPLE_COMMON}; |
| 21 | std::set<enum llama_example> excludes = {}; |
| 22 | std::vector<const char *> args; |
| 23 | std::vector<const char *> args_neg; // for negated args like --no-xxx |
| 24 | const char * value_hint = nullptr; // help text or example for arg value |
| 25 | const char * value_hint_2 = nullptr; // for second arg value |
| 26 | const char * env = nullptr; |
| 27 | std::string help; |
| 28 | bool is_sparam = false; // is current arg a sampling param? |
| 29 | bool is_preset_only = false; // is current arg preset-only (not treated as CLI arg) |
| 30 | void (*handler_void) (common_params & params) = nullptr; |
| 31 | void (*handler_string) (common_params & params, const std::string &) = nullptr; |
| 32 | void (*handler_str_str)(common_params & params, const std::string &, const std::string &) = nullptr; |
| 33 | void (*handler_int) (common_params & params, int) = nullptr; |
| 34 | void (*handler_bool) (common_params & params, bool) = nullptr; |
| 35 | |
| 36 | common_arg() = default; |
| 37 | |
| 38 | common_arg( |
| 39 | const std::initializer_list<const char *> & args, |
| 40 | const char * value_hint, |
| 41 | const std::string & help, |
| 42 | void (*handler)(common_params & params, const std::string &) |
| 43 | ) : args(args), value_hint(value_hint), help(help), handler_string(handler) {} |
| 44 | |
| 45 | common_arg( |
| 46 | const std::initializer_list<const char *> & args, |
| 47 | const char * value_hint, |
| 48 | const std::string & help, |
| 49 | void (*handler)(common_params & params, int) |
| 50 | ) : args(args), value_hint(value_hint), help(help), handler_int(handler) {} |
| 51 | |
| 52 | common_arg( |
| 53 | const std::initializer_list<const char *> & args, |
| 54 | const std::string & help, |
| 55 | void (*handler)(common_params & params) |
| 56 | ) : args(args), help(help), handler_void(handler) {} |
| 57 | |
| 58 | common_arg( |
| 59 | const std::initializer_list<const char *> & args, |
| 60 | const std::initializer_list<const char *> & args_neg, |
| 61 | const std::string & help, |
| 62 | void (*handler)(common_params & params, bool) |
| 63 | ) : args(args), args_neg(args_neg), help(help), handler_bool(handler) {} |
| 64 | |
| 65 | // support 2 values for arg |
| 66 | common_arg( |
| 67 | const std::initializer_list<const char *> & args, |
| 68 | const char * value_hint, |
| 69 | const char * value_hint_2, |
| 70 | const std::string & help, |
| 71 | void (*handler)(common_params & params, const std::string &, const std::string &) |
| 72 | ) : args(args), value_hint(value_hint), value_hint_2(value_hint_2), help(help), handler_str_str(handler) {} |
| 73 | |
| 74 | common_arg & set_examples(std::initializer_list<enum llama_example> examples); |
| 75 | common_arg & set_excludes(std::initializer_list<enum llama_example> excludes); |
| 76 | common_arg & set_env(const char * env); |
no outgoing calls
no test coverage detected