diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-10-12 15:36:45 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-10-12 15:36:45 +0200 |
commit | f6cdae5181fb32231d75439635106e3d093931ad (patch) | |
tree | 6b164493d9e7cedc182e1bd501656df212a2f2d5 /src/nix | |
parent | 9ebe02a81e6ecb15abaa695c26b3773ce46ef155 (diff) |
nix repl: Don't write to std::cout directly
Writing to std::cout doesn't play nice with ProgressBar.
Diffstat (limited to 'src/nix')
-rw-r--r-- | src/nix/repl.cc | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/nix/repl.cc b/src/nix/repl.cc index fb33fc23e..68ed04a13 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -200,13 +200,13 @@ namespace { void NixRepl::mainLoop(const std::vector<std::string> & files) { string error = ANSI_RED "error:" ANSI_NORMAL " "; - std::cout << "Welcome to Nix version " << nixVersion << ". Type :? for help." << std::endl << std::endl; + notice("Welcome to Nix " + nixVersion + ". Type :? for help.\n"); for (auto & i : files) loadedFiles.push_back(i); reloadFiles(); - if (!loadedFiles.empty()) std::cout << std::endl; + if (!loadedFiles.empty()) notice(""); // Allow nix-repl specific settings in .inputrc rl_readline_name = "nix-repl"; @@ -479,9 +479,10 @@ bool NixRepl::processLine(string line) else if (command == ":t") { Value v; evalString(arg, v); - std::cout << showType(v) << std::endl; + logger->cout(showType(v)); + } - } else if (command == ":u") { + else if (command == ":u") { Value v, f, result; evalString(arg, v); evalString("drv: (import <nixpkgs> {}).runCommand \"shell\" { buildInputs = [ drv ]; } \"\"", f); @@ -535,9 +536,9 @@ bool NixRepl::processLine(string line) + concatStringsSep(" ", args) + "\n\n"; } - markdown += trim(stripIndentation(doc->doc)); + markdown += stripIndentation(doc->doc); - std::cout << renderMarkdownToTerminal(markdown); + logger->cout(trim(renderMarkdownToTerminal(markdown))); } else throw Error("value does not have documentation"); } @@ -620,9 +621,9 @@ void NixRepl::reloadFiles() bool first = true; for (auto & i : old) { - if (!first) std::cout << std::endl; + if (!first) notice(""); first = false; - std::cout << format("Loading '%1%'...") % i << std::endl; + notice("Loading '%1%'...", i); loadFile(i); } } @@ -633,7 +634,7 @@ void NixRepl::addAttrsToScope(Value & attrs) state->forceAttrs(attrs); for (auto & i : *attrs.attrs) addVarToScope(i.name, *i.value); - std::cout << format("Added %1% variables.") % attrs.attrs->size() << std::endl; + notice("Added %1% variables.", attrs.attrs->size()); } |