diff --git a/globs.cc b/globs.cc index ebfc12d..e3f1da5 100644 --- a/globs.cc +++ b/globs.cc @@ -159,27 +159,4 @@ void cs_register_globs(cscript::CsState &cs) { auto fnames = cscript::util::list_explode(lst); cs.result->set_str(ob_expand_globs(fnames).disown()); }); - - cs.add_command("extreplace", "sss", [](cscript::CsState &cs, - const char *lst, - const char *oldext, - const char *newext) { - String ret; - if (oldext[0] == '.') ++oldext; - if (newext[0] == '.') ++newext; - auto fnames = cscript::util::list_explode(lst); - for (ConstCharRange it: fnames.iter()) { - if (!ret.empty()) ret += ' '; - auto dot = ostd::find_last(it, '.'); - if (!dot.empty() && ((dot + 1) == oldext)) { - ret += ostd::slice_until(it, dot); - ret += '.'; - ret += newext; - } else { - ret += it; - } - } - cs.result->set_str(ret.iter()); - ret.disown(); - }); } \ No newline at end of file diff --git a/main.cc b/main.cc index 4f0dd84..b444fe8 100644 --- a/main.cc +++ b/main.cc @@ -454,6 +454,29 @@ int main(int argc, char **argv) { } }); + os.cs.add_command("extreplace", "sss", [](cscript::CsState &cs, + const char *lst, + const char *oldext, + const char *newext) { + String ret; + if (oldext[0] == '.') ++oldext; + if (newext[0] == '.') ++newext; + auto fnames = cscript::util::list_explode(lst); + for (ConstCharRange it: fnames.iter()) { + if (!ret.empty()) ret += ' '; + auto dot = ostd::find_last(it, '.'); + if (!dot.empty() && ((dot + 1) == oldext)) { + ret += ostd::slice_until(it, dot); + ret += '.'; + ret += newext; + } else { + ret += it; + } + } + cs.result->set_str(ret.iter()); + ret.disown(); + }); + os.cs.add_command("invoke", "s", [](CsState &cs, const char *name) { cs.result->set_int(((ObState &)cs).exec_main(name)); });