161 std::unique_ptr<BackendSection> backend;
162 std::vector<ActionSection> pre;
163 std::vector<ActionSection> post;
169 std::map<std::string, std::function<void(
const std::string &arg)>> argparse;
171 argparse[
"--backend"] = [§ions](
const std::string &tag) {
172 sections.backend = std::make_unique<BackendSection>(tag);
175 argparse[
"--backend-arg"] = [§ions](
const std::string &arg) {
176 sections.backend->append(arg);
179 argparse[
"--pre"] = [§ions](
const std::string &tag) { sections.pre.emplace_back(tag); };
181 argparse[
"--pre-arg"] = [§ions](
const std::string &arg) { sections.pre.back().append(arg); };
183 argparse[
"--post"] = [§ions](
const std::string &tag) { sections.post.emplace_back(tag); };
185 argparse[
"--post-arg"] = [§ions](
const std::string &arg) {
186 sections.post.back().append(arg);
191 std::cerr <<
"Usage:" << std::endl
192 <<
"[Command] --backend [Backend module path] "
193 <<
"--backend-arg [Backend argument] ..." << std::endl
194 <<
" --pre [Pre-Action module path] "
195 <<
"--pre-arg [Pre-Action argument] ..." << std::endl
196 <<
" --post [Post-Action module path] "
197 <<
"--post-arg [Post-Action argument] ..." << std::endl;
201 for (
int n = 1; n < argc; n += 2)
203 const std::string tag{argv[n]};
204 const std::string arg{argv[n + 1]};
206 auto it = argparse.find(tag);
208 if (it == argparse.end())
210 std::cerr <<
"Option '" << tag <<
"' is not supported" << std::endl;
218 if (sections.backend ==
nullptr)
220 std::cerr <<
"Error: Backend is required. Provide with [--backend]" << std::endl;
225 auto backend = sections.backend->initialize();
228 std::vector<std::unique_ptr<nnkit::Action>> pre_actions;
230 for (
const auto §ion : sections.pre)
232 pre_actions.emplace_back(section.initialize());
236 std::vector<std::unique_ptr<nnkit::Action>> post_actions;
238 for (
const auto §ion : sections.post)
240 post_actions.emplace_back(section.initialize());
248 for (
auto &action : pre_actions)
258 for (
auto &action : post_actions)