lichao
2021-05-06 0117d5f8ff386075b0c4cbec0cbe460fe3cfa680
box/box.cc
@@ -76,13 +76,24 @@
}
const std::string kOrigName("bhshmqbox");
inline void PrintLn() { putchar('\n'); }
template <class... Params>
void PrintLn(const char *fmt, Params &&...t)
{
   printf(fmt, std::forward<decltype(t)>(t)...);
   PrintLn();
}
void Help()
{
   printf("%s : bhome shared memory message queue box application.\n", kOrigName.c_str());
   printf("usage:\n");
   printf("\t1) %s [function [options]...]\n", kOrigName.c_str());
   printf("\t2) rename or link %s to a function name then run it directly.\n", kOrigName.c_str());
   printf("\nsupported functions:\n");
   PrintLn("%s : bhome shared memory message queue box application.", kOrigName.c_str());
   PrintLn("usage:");
   PrintLn("\t1) %s [function [options]...]", kOrigName.c_str());
   PrintLn("\t2) rename or link %s to a function name then run it directly.", kOrigName.c_str());
   PrintLn();
   PrintLn("supported functions:");
   std::map<std::string, std::string> funcs;
   auto getInfo = [&](const std::string &name, const std::string &desc) {
      funcs[name] = desc;
@@ -92,9 +103,10 @@
   int max_len = std::max_element(funcs.begin(), funcs.end(), cmp_name_len)->first.size();
   for (auto &kv : funcs) {
      int npad = max_len - kv.first.size();
      printf("\n\t%s%s : %s\n", kv.first.c_str(), std::string(npad, ' ').c_str(), kv.second.c_str());
      PrintLn();
      PrintLn("\t%s%s : %s", kv.first.c_str(), std::string(npad, ' ').c_str(), kv.second.c_str());
   }
   printf("\n");
   PrintLn();
}
int BoxMain(int argc, const char *argv[])
@@ -106,7 +118,7 @@
   if (BoxFind(name, func)) {
      return func(argc, argv);
   } else {
      printf("%s : function not found!\n", name.c_str());
      PrintLn("%s : function not found!", name.c_str());
      // Help();
   }
   return 0;
@@ -119,7 +131,7 @@
   fs::path exe(argv[0]);
   auto name = exe.filename().string();
   // printf("name: %s\n", name.c_str());
   // PrintLn("name: %s", name.c_str());
   if (name == kOrigName) {
      if (argc > 1) {