MCPcopy Create free account
hub / github.com/Colvars/colvars / init_command

Method init_command

src/colvarscript.cpp:90–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88
89
90int colvarscript::init_command(colvarscript::command const &comm,
91 char const *name, char const *help,
92 int n_args_min, int n_args_max,
93 char const *arghelp,
94 int (*fn)(void *, int, unsigned char * const *))
95{
96 cmd_str_map[std::string(name)] = comm;
97 cmd_names[comm] = name;
98 cmd_help[comm] = help;
99 cmd_n_args_min[comm] = n_args_min;
100 cmd_n_args_max[comm] = n_args_max;
101 std::string const arghelp_str(arghelp);
102 std::istringstream is(arghelp_str);
103 std::string line;
104 for (int iarg = 0; iarg < n_args_max; iarg++) {
105 if (! std::getline(is, line)) {
106 return cvm::error("Error: could not initialize help string for scripting "
107 "command \""+std::string(name)+"\".\n", BUG_ERROR);
108 }
109 cmd_arghelp[comm].push_back(line);
110 }
111 cmd_fns[comm] = fn;
112 if (cvm::debug()) {
113 cvm::log("Defined command \""+std::string(name)+"\", with help string:\n");
114 cvm::log(get_command_help(name));
115 }
116 return COLVARS_OK;
117}
118
119
120std::string colvarscript::get_cmd_prefix(colvarscript::Object_type t)

Callers

nothing calls this directly

Calls 2

errorFunction · 0.50
logFunction · 0.50

Tested by

no test coverage detected