Commit b726fc1a authored by Paul's avatar Paul
Browse files

Formatting

parent 058470c8
...@@ -88,8 +88,7 @@ struct argument_parser ...@@ -88,8 +88,7 @@ struct argument_parser
static auto write_action(F f) static auto write_action(F f)
{ {
return [=](auto& x, auto& arg) { return [=](auto& x, auto& arg) {
arg.action = [&, f](auto& self, const std::vector<std::string>& params) arg.action = [&, f](auto& self, const std::vector<std::string>& params) {
{
f(self, x, params); f(self, x, params);
return false; return false;
}; };
...@@ -100,8 +99,7 @@ struct argument_parser ...@@ -100,8 +99,7 @@ struct argument_parser
static auto do_action(F f) static auto do_action(F f)
{ {
return [=](auto&, auto& arg) { return [=](auto&, auto& arg) {
arg.action = [&, f](auto& self, const std::vector<std::string>&) arg.action = [&, f](auto& self, const std::vector<std::string>&) {
{
f(self); f(self);
return true; return true;
}; };
...@@ -138,7 +136,7 @@ struct argument_parser ...@@ -138,7 +136,7 @@ struct argument_parser
std::cout << " " << arg.help << std::endl; std::cout << " " << arg.help << std::endl;
} }
std::cout << std::endl; std::cout << std::endl;
if (not msg.empty()) if(not msg.empty())
std::cout << msg << std::endl; std::cout << msg << std::endl;
}); });
} }
...@@ -153,8 +151,7 @@ struct argument_parser ...@@ -153,8 +151,7 @@ struct argument_parser
{ {
return [=](auto& x, auto& arg) { return [=](auto& x, auto& arg) {
arg.type = ""; arg.type = "";
arg.action = [&, value](auto&, const std::vector<std::string>&) arg.action = [&, value](auto&, const std::vector<std::string>&) {
{
x = value; x = value;
return false; return false;
}; };
......
...@@ -19,7 +19,7 @@ inline auto& get_commands() ...@@ -19,7 +19,7 @@ inline auto& get_commands()
return m; return m;
} }
template<class T> template <class T>
std::string command_name() std::string command_name()
{ {
static const std::string& name = get_type_name<T>(); static const std::string& name = get_type_name<T>();
...@@ -29,7 +29,7 @@ std::string command_name() ...@@ -29,7 +29,7 @@ std::string command_name()
template <class T> template <class T>
int auto_register_command() int auto_register_command()
{ {
auto& m = get_commands(); auto& m = get_commands();
m[command_name<T>()] = [](std::vector<std::string> args) { m[command_name<T>()] = [](std::vector<std::string> args) {
T x; T x;
argument_parser ap; argument_parser ap;
......
...@@ -6,7 +6,7 @@ struct main_command ...@@ -6,7 +6,7 @@ struct main_command
static std::string get_command_help() static std::string get_command_help()
{ {
std::string result = "Commands:\n"; std::string result = "Commands:\n";
for(const auto& p:migraphx::driver::get_commands()) for(const auto& p : migraphx::driver::get_commands())
result += " " + p.first + "\n"; result += " " + p.first + "\n";
return result; return result;
} }
...@@ -18,23 +18,24 @@ struct main_command ...@@ -18,23 +18,24 @@ struct main_command
void run() {} void run() {}
}; };
int main(int argc, const char* argv[]) { int main(int argc, const char* argv[])
{
std::vector<std::string> args(argv + 1, argv + argc); std::vector<std::string> args(argv + 1, argv + argc);
if (args.empty()) if(args.empty())
return 0; return 0;
auto&& m = migraphx::driver::get_commands(); auto&& m = migraphx::driver::get_commands();
auto cmd = args.front(); auto cmd = args.front();
if (m.count(cmd) > 0) if(m.count(cmd) > 0)
{ {
m.at(cmd)({args.begin()+1, args.end()}); m.at(cmd)({args.begin() + 1, args.end()});
} }
else else
{ {
migraphx::driver::argument_parser ap; migraphx::driver::argument_parser ap;
main_command mc; main_command mc;
mc.parse(ap); mc.parse(ap);
ap.parse(args); ap.parse(args);
mc.run(); mc.run();
} }
return 0; return 0;
} }
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