aboutsummaryrefslogtreecommitdiff
path: root/src/libmain/progress-bar.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-11-26 12:34:43 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-11-26 12:37:23 +0100
commit0287f8305790a87b128ce09d7d3fa0de7104673c (patch)
tree2797e8ced31d95780bcb60735095c1746cde5f80 /src/libmain/progress-bar.cc
parent605bacdc929db4d820b8d5866450de7d1ec6e6cf (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.cc11
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)