"library/vscode:/vscode.git/clone" did not exist on "ada0add89be0da299be3a59e52071be4ea6669e8"
Commit f0c57f28 authored by Paul's avatar Paul
Browse files

Shortedn call to add args

parent 90aca5c3
......@@ -62,7 +62,7 @@ struct argument_parser
};
template <class T, class... Fs>
void add(T& x, std::vector<std::string> flags, Fs... fs)
void operator()(T& x, std::vector<std::string> flags, Fs... fs)
{
arguments.push_back({flags, [&](auto&&, const std::vector<std::string>& params) {
if(params.empty())
......@@ -77,7 +77,7 @@ struct argument_parser
}
template <class... Fs>
void add(std::nullptr_t x, std::vector<std::string> flags, Fs... fs)
void operator()(std::nullptr_t x, std::vector<std::string> flags, Fs... fs)
{
arguments.push_back({flags});
......
......@@ -32,7 +32,7 @@ void run_command(std::vector<std::string> args, bool add_help = false)
T x;
argument_parser ap;
if(add_help)
ap.add(nullptr, {"-h", "--help"}, ap.help("Show help"), ap.show_help());
ap(nullptr, {"-h", "--help"}, ap.help("Show help"), ap.show_help());
x.parse(ap);
if(ap.parse(args))
return;
......
......@@ -19,13 +19,13 @@ struct loader
void parse(argument_parser& ap)
{
ap.add(file, {}, ap.metavar("<input file>"));
ap.add(type, {"--onnx"}, ap.help("Load as onnx"), ap.set_value("onnx"));
ap.add(type, {"--tf"}, ap.help("Load as tensorflow"), ap.set_value("tf"));
ap.add(is_nhwc, {"--nhwc"}, ap.help("Treat tensorflow format as nhwc"), ap.set_value(true));
ap.add(
ap(file, {}, ap.metavar("<input file>"));
ap(type, {"--onnx"}, ap.help("Load as onnx"), ap.set_value("onnx"));
ap(type, {"--tf"}, ap.help("Load as tensorflow"), ap.set_value("tf"));
ap(is_nhwc, {"--nhwc"}, ap.help("Treat tensorflow format as nhwc"), ap.set_value(true));
ap(
is_nhwc, {"--nchw"}, ap.help("Treat tensorflow format as nchw"), ap.set_value(false));
ap.add(trim, {"--trim", "-t"}, ap.help("Trim instructions from the end"));
ap(trim, {"--trim", "-t"}, ap.help("Trim instructions from the end"));
}
program load()
......@@ -73,12 +73,12 @@ struct verify : command<verify>
void parse(argument_parser& ap)
{
l.parse(ap);
ap.add(tolerance, {"--tolerance"}, ap.help("Tolerance for errors"));
ap.add(per_instruction,
ap(tolerance, {"--tolerance"}, ap.help("Tolerance for errors"));
ap(per_instruction,
{"-i", "--per-instruction"},
ap.help("Verify each instruction"),
ap.set_value(true));
ap.add(
ap(
reduce, {"-r", "--reduce"}, ap.help("Reduce program and verify"), ap.set_value(true));
}
......@@ -113,7 +113,7 @@ struct main_command
}
void parse(argument_parser& ap)
{
ap.add(nullptr, {"-h", "--help"}, ap.help("Show help"), ap.show_help(get_command_help()));
ap(nullptr, {"-h", "--help"}, ap.help("Show help"), ap.show_help(get_command_help()));
}
void run() {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment