diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-11-26 12:34:43 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-11-26 12:37:23 +0100 |
commit | 0287f8305790a87b128ce09d7d3fa0de7104673c (patch) | |
tree | 2797e8ced31d95780bcb60735095c1746cde5f80 /src/libmain/progress-bar.cc | |
parent | 605bacdc929db4d820b8d5866450de7d1ec6e6cf (diff) |
Ask for confirmation before allowing flake Nix configuration settings
Diffstat (limited to 'src/libmain/progress-bar.cc')
-rw-r--r-- | src/libmain/progress-bar.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libmain/progress-bar.cc b/src/libmain/progress-bar.cc index 07b45b3b5..0e5432fca 100644 --- a/src/libmain/progress-bar.cc +++ b/src/libmain/progress-bar.cc @@ -466,6 +466,17 @@ public: Logger::writeToStdout(s); } } + + std::optional<char> ask(std::string_view msg) override + { + auto state(state_.lock()); + if (!state->active || !isatty(STDIN_FILENO)) return {}; + std::cerr << fmt("\r\e[K%s ", msg); + auto s = trim(readLine(STDIN_FILENO)); + if (s.size() != 1) return {}; + draw(*state); + return s[0]; + } }; Logger * makeProgressBar(bool printBuildLogs) |