Add '-y' flag for hecl

This commit is contained in:
Jack Andersen 2016-03-23 16:51:57 -10:00
parent 51d4caf252
commit d35408376c
4 changed files with 31 additions and 25 deletions

View File

@ -26,6 +26,7 @@ struct ToolPassInfo
hecl::Database::Project* project = nullptr;
unsigned verbosityLevel = 0;
bool force = false;
bool yes = false;
};
class ToolBase

View File

@ -121,7 +121,7 @@ public:
hecl::Printf(_S("" BOLD "%s" NORMAL ""), rep.name.c_str());
else
hecl::Printf(_S("%s"), rep.name.c_str());
if (rep.desc.size())
hecl::Printf(_S(" [%s]"), rep.desc.c_str());
hecl::Printf(_S("\n"));
@ -151,31 +151,34 @@ public:
hecl::Printf(_S("\n"));
}
if (XTERM_COLOR)
hecl::Printf(_S("\n" BLUE BOLD "Continue?" NORMAL " (Y/n) "));
else
hecl::Printf(_S("\nContinue? (Y/n) "));
int ch;
#ifndef _WIN32
struct termios tioOld, tioNew;
tcgetattr(0, &tioOld);
tioNew = tioOld;
tioNew.c_lflag &= ~ICANON;
tcsetattr(0, TCSANOW, &tioNew);
while ((ch = getchar()))
#else
while ((ch = getch()))
#endif
if (!m_info.yes)
{
if (ch == 'n' || ch == 'N')
return 0;
if (ch == 'y' || ch == 'Y' || ch == '\r' || ch == '\n')
break;
}
if (XTERM_COLOR)
hecl::Printf(_S("\n" BLUE BOLD "Continue?" NORMAL " (Y/n) "));
else
hecl::Printf(_S("\nContinue? (Y/n) "));
int ch;
#ifndef _WIN32
tcsetattr(0, TCSANOW, &tioOld);
struct termios tioOld, tioNew;
tcgetattr(0, &tioOld);
tioNew = tioOld;
tioNew.c_lflag &= ~ICANON;
tcsetattr(0, TCSANOW, &tioNew);
while ((ch = getchar()))
#else
while ((ch = getch()))
#endif
{
if (ch == 'n' || ch == 'N')
return 0;
if (ch == 'y' || ch == 'Y' || ch == '\r' || ch == '\n')
break;
}
#ifndef _WIN32
tcsetattr(0, TCSANOW, &tioOld);
#endif
}
hecl::Printf(_S("\n"));

View File

@ -96,7 +96,7 @@ int main(int argc, const char** argv)
#else
std::setlocale(LC_ALL, "en-US.UTF-8");
#endif
/* Xterm check */
#if _WIN32
const char* conemuANSI = getenv("ConEmuANSI");
@ -201,6 +201,8 @@ int main(int argc, const char** argv)
++info.verbosityLevel;
else if (*chit == _S('f'))
info.force = true;
else if (*chit == _S('y'))
info.yes = true;
else
info.flags.push_back(*chit);
}

2
hecl/extern/boo vendored

@ -1 +1 @@
Subproject commit 1eb46301c0e56cf33df173396029841c960e42fd
Subproject commit ca38805776c814034af28f68144de64868601da1