stdout_ -> cout

Better to get creative than just sprinkle arbitrary underscores.
This commit is contained in:
John Ericson 2020-09-25 11:30:04 -04:00
parent ec14465a00
commit cfe791a638
11 changed files with 33 additions and 33 deletions

View file

@ -100,7 +100,7 @@ public:
virtual void writeToStdout(std::string_view s); virtual void writeToStdout(std::string_view s);
template<typename... Args> template<typename... Args>
inline void stdout_(const std::string & fs, const Args & ... args) inline void cout(const std::string & fs, const Args & ... args)
{ {
boost::format f(fs); boost::format f(fs);
formatHelper(f, args...); formatHelper(f, args...);

View file

@ -83,7 +83,7 @@ struct CmdAddToStore : MixDryRun, StoreCommand
store->addToStore(info, source); store->addToStore(info, source);
} }
logger->stdout_("%s", store->printStorePath(info.path)); logger->cout("%s", store->printStorePath(info.path));
} }
}; };

View file

@ -85,7 +85,7 @@ struct CmdEval : MixJSON, InstallableCommand
printValueAsJSON(*state, true, *v, jsonOut, context); printValueAsJSON(*state, true, *v, jsonOut, context);
} else { } else {
state->forceValueDeep(*v); state->forceValueDeep(*v);
logger->stdout_("%s", *v); logger->cout("%s", *v);
} }
} }
}; };

View file

@ -62,17 +62,17 @@ public:
static void printFlakeInfo(const Store & store, const Flake & flake) static void printFlakeInfo(const Store & store, const Flake & flake)
{ {
logger->stdout_("Resolved URL: %s", flake.resolvedRef.to_string()); logger->cout("Resolved URL: %s", flake.resolvedRef.to_string());
logger->stdout_("Locked URL: %s", flake.lockedRef.to_string()); logger->cout("Locked URL: %s", flake.lockedRef.to_string());
if (flake.description) if (flake.description)
logger->stdout_("Description: %s", *flake.description); logger->cout("Description: %s", *flake.description);
logger->stdout_("Path: %s", store.printStorePath(flake.sourceInfo->storePath)); logger->cout("Path: %s", store.printStorePath(flake.sourceInfo->storePath));
if (auto rev = flake.lockedRef.input.getRev()) if (auto rev = flake.lockedRef.input.getRev())
logger->stdout_("Revision: %s", rev->to_string(Base16, false)); logger->cout("Revision: %s", rev->to_string(Base16, false));
if (auto revCount = flake.lockedRef.input.getRevCount()) if (auto revCount = flake.lockedRef.input.getRevCount())
logger->stdout_("Revisions: %s", *revCount); logger->cout("Revisions: %s", *revCount);
if (auto lastModified = flake.lockedRef.input.getLastModified()) if (auto lastModified = flake.lockedRef.input.getLastModified())
logger->stdout_("Last modified: %s", logger->cout("Last modified: %s",
std::put_time(std::localtime(&*lastModified), "%F %T")); std::put_time(std::localtime(&*lastModified), "%F %T"));
} }
@ -140,7 +140,7 @@ struct CmdFlakeInfo : FlakeCommand, MixJSON
if (json) { if (json) {
auto json = flakeToJson(*store, flake); auto json = flakeToJson(*store, flake);
logger->stdout_("%s", json.dump()); logger->cout("%s", json.dump());
} else } else
printFlakeInfo(*store, flake); printFlakeInfo(*store, flake);
} }
@ -158,9 +158,9 @@ struct CmdFlakeListInputs : FlakeCommand, MixJSON
auto flake = lockFlake(); auto flake = lockFlake();
if (json) if (json)
logger->stdout_("%s", flake.lockFile.toJson()); logger->cout("%s", flake.lockFile.toJson());
else { else {
logger->stdout_("%s", flake.flake.lockedRef); logger->cout("%s", flake.flake.lockedRef);
std::unordered_set<std::shared_ptr<Node>> visited; std::unordered_set<std::shared_ptr<Node>> visited;
@ -172,7 +172,7 @@ struct CmdFlakeListInputs : FlakeCommand, MixJSON
bool last = i + 1 == node.inputs.size(); bool last = i + 1 == node.inputs.size();
if (auto lockedNode = std::get_if<0>(&input.second)) { if (auto lockedNode = std::get_if<0>(&input.second)) {
logger->stdout_("%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s", logger->cout("%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s",
prefix + (last ? treeLast : treeConn), input.first, prefix + (last ? treeLast : treeConn), input.first,
*lockedNode ? (*lockedNode)->lockedRef : flake.flake.lockedRef); *lockedNode ? (*lockedNode)->lockedRef : flake.flake.lockedRef);
@ -180,7 +180,7 @@ struct CmdFlakeListInputs : FlakeCommand, MixJSON
if (firstVisit) recurse(**lockedNode, prefix + (last ? treeNull : treeLine)); if (firstVisit) recurse(**lockedNode, prefix + (last ? treeNull : treeLine));
} else if (auto follows = std::get_if<1>(&input.second)) { } else if (auto follows = std::get_if<1>(&input.second)) {
logger->stdout_("%s" ANSI_BOLD "%s" ANSI_NORMAL " follows input '%s'", logger->cout("%s" ANSI_BOLD "%s" ANSI_NORMAL " follows input '%s'",
prefix + (last ? treeLast : treeConn), input.first, prefix + (last ? treeLast : treeConn), input.first,
printInputPath(*follows)); printInputPath(*follows));
} }
@ -811,7 +811,7 @@ struct CmdFlakeShow : FlakeCommand
try { try {
auto recurse = [&]() auto recurse = [&]()
{ {
logger->stdout_("%s", headerPrefix); logger->cout("%s", headerPrefix);
auto attrs = visitor.getAttrs(); auto attrs = visitor.getAttrs();
for (const auto & [i, attr] : enumerate(attrs)) { for (const auto & [i, attr] : enumerate(attrs)) {
bool last = i + 1 == attrs.size(); bool last = i + 1 == attrs.size();
@ -837,7 +837,7 @@ struct CmdFlakeShow : FlakeCommand
} }
*/ */
logger->stdout_("%s: %s '%s'", logger->cout("%s: %s '%s'",
headerPrefix, headerPrefix,
attrPath.size() == 2 && attrPath[0] == "devShell" ? "development environment" : attrPath.size() == 2 && attrPath[0] == "devShell" ? "development environment" :
attrPath.size() == 3 && attrPath[0] == "checks" ? "derivation" : attrPath.size() == 3 && attrPath[0] == "checks" ? "derivation" :
@ -885,7 +885,7 @@ struct CmdFlakeShow : FlakeCommand
if (attrPath.size() == 1) if (attrPath.size() == 1)
recurse(); recurse();
else if (!showLegacy) else if (!showLegacy)
logger->stdout_("%s: " ANSI_YELLOW "omitted" ANSI_NORMAL " (use '--legacy' to show)", headerPrefix); logger->cout("%s: " ANSI_YELLOW "omitted" ANSI_NORMAL " (use '--legacy' to show)", headerPrefix);
else { else {
if (visitor.isDerivation()) if (visitor.isDerivation())
showDerivation(); showDerivation();
@ -902,7 +902,7 @@ struct CmdFlakeShow : FlakeCommand
auto aType = visitor.maybeGetAttr("type"); auto aType = visitor.maybeGetAttr("type");
if (!aType || aType->getString() != "app") if (!aType || aType->getString() != "app")
throw EvalError("not an app definition"); throw EvalError("not an app definition");
logger->stdout_("%s: app", headerPrefix); logger->cout("%s: app", headerPrefix);
} }
else if ( else if (
@ -910,11 +910,11 @@ struct CmdFlakeShow : FlakeCommand
(attrPath.size() == 2 && attrPath[0] == "templates")) (attrPath.size() == 2 && attrPath[0] == "templates"))
{ {
auto description = visitor.getAttr("description")->getString(); auto description = visitor.getAttr("description")->getString();
logger->stdout_("%s: template: " ANSI_BOLD "%s" ANSI_NORMAL, headerPrefix, description); logger->cout("%s: template: " ANSI_BOLD "%s" ANSI_NORMAL, headerPrefix, description);
} }
else { else {
logger->stdout_("%s: %s", logger->cout("%s: %s",
headerPrefix, headerPrefix,
attrPath.size() == 1 && attrPath[0] == "overlay" ? "Nixpkgs overlay" : attrPath.size() == 1 && attrPath[0] == "overlay" ? "Nixpkgs overlay" :
attrPath.size() == 2 && attrPath[0] == "nixosConfigurations" ? "NixOS configuration" : attrPath.size() == 2 && attrPath[0] == "nixosConfigurations" ? "NixOS configuration" :

View file

@ -73,7 +73,7 @@ struct CmdHash : Command
Hash h = hashSink->finish().first; Hash h = hashSink->finish().first;
if (truncate && h.hashSize > 20) h = compressHash(h, 20); if (truncate && h.hashSize > 20) h = compressHash(h, 20);
logger->stdout_(h.to_string(base, base == SRI)); logger->cout(h.to_string(base, base == SRI));
} }
} }
}; };
@ -107,7 +107,7 @@ struct CmdToBase : Command
void run() override void run() override
{ {
for (auto s : args) for (auto s : args)
logger->stdout_(Hash::parseAny(s, ht).to_string(base, base == SRI)); logger->cout(Hash::parseAny(s, ht).to_string(base, base == SRI));
} }
}; };

View file

@ -37,11 +37,11 @@ struct MixLs : virtual Args, MixJSON
auto line = fmt("%s %20d %s", tp, st.fileSize, relPath); auto line = fmt("%s %20d %s", tp, st.fileSize, relPath);
if (st.type == FSAccessor::Type::tSymlink) if (st.type == FSAccessor::Type::tSymlink)
line += " -> " + accessor->readLink(curPath); line += " -> " + accessor->readLink(curPath);
logger->stdout_(line); logger->cout(line);
if (recursive && st.type == FSAccessor::Type::tDirectory) if (recursive && st.type == FSAccessor::Type::tDirectory)
doPath(st, curPath, relPath, false); doPath(st, curPath, relPath, false);
} else { } else {
logger->stdout_(relPath); logger->cout(relPath);
if (recursive) { if (recursive) {
auto st = accessor->stat(curPath); auto st = accessor->stat(curPath);
if (st.type == FSAccessor::Type::tDirectory) if (st.type == FSAccessor::Type::tDirectory)

View file

@ -389,7 +389,7 @@ struct CmdProfileInfo : virtual EvalCommand, virtual StoreCommand, MixDefaultPro
for (size_t i = 0; i < manifest.elements.size(); ++i) { for (size_t i = 0; i < manifest.elements.size(); ++i) {
auto & element(manifest.elements[i]); auto & element(manifest.elements[i]);
logger->stdout_("%d %s %s %s", i, logger->cout("%d %s %s %s", i,
element.source ? element.source->originalRef.to_string() + "#" + element.source->attrPath : "-", element.source ? element.source->originalRef.to_string() + "#" + element.source->attrPath : "-",
element.source ? element.source->resolvedRef.to_string() + "#" + element.source->attrPath : "-", element.source ? element.source->resolvedRef.to_string() + "#" + element.source->attrPath : "-",
concatStringsSep(" ", store->printStorePathSet(element.storePaths))); concatStringsSep(" ", store->printStorePathSet(element.storePaths)));

View file

@ -26,7 +26,7 @@ struct CmdRegistryList : StoreCommand
for (auto & registry : registries) { for (auto & registry : registries) {
for (auto & entry : registry->entries) { for (auto & entry : registry->entries) {
// FIXME: format nicely // FIXME: format nicely
logger->stdout_("%s %s %s", logger->cout("%s %s %s",
registry->type == Registry::Flag ? "flags " : registry->type == Registry::Flag ? "flags " :
registry->type == Registry::User ? "user " : registry->type == Registry::User ? "user " :
registry->type == Registry::System ? "system" : registry->type == Registry::System ? "system" :

View file

@ -147,13 +147,13 @@ struct CmdSearch : InstallableCommand, MixJSON
jsonElem.attr("description", description); jsonElem.attr("description", description);
} else { } else {
auto name2 = hilite(name.name, nameMatch, "\e[0;2m"); auto name2 = hilite(name.name, nameMatch, "\e[0;2m");
if (results > 1) logger->stdout_(""); if (results > 1) logger->cout("");
logger->stdout_( logger->cout(
"* %s%s", "* %s%s",
wrap("\e[0;1m", hilite(attrPath2, attrPathMatch, "\e[0;1m")), wrap("\e[0;1m", hilite(attrPath2, attrPathMatch, "\e[0;1m")),
name.version != "" ? " (" + name.version + ")" : ""); name.version != "" ? " (" + name.version + ")" : "");
if (description != "") if (description != "")
logger->stdout_( logger->cout(
" %s", hilite(description, descriptionMatch, ANSI_NORMAL)); " %s", hilite(description, descriptionMatch, ANSI_NORMAL));
} }
} }

View file

@ -20,12 +20,12 @@ struct CmdShowConfig : Command, MixJSON
{ {
if (json) { if (json) {
// FIXME: use appropriate JSON types (bool, ints, etc). // FIXME: use appropriate JSON types (bool, ints, etc).
logger->stdout_("%s", globalConfig.toJSON().dump()); logger->cout("%s", globalConfig.toJSON().dump());
} else { } else {
std::map<std::string, Config::SettingInfo> settings; std::map<std::string, Config::SettingInfo> settings;
globalConfig.getSettings(settings); globalConfig.getSettings(settings);
for (auto & s : settings) for (auto & s : settings)
logger->stdout_("%s = %s", s.first, s.second.value); logger->cout("%s = %s", s.first, s.second.value);
} }
} }
}; };

View file

@ -156,7 +156,7 @@ struct CmdWhyDepends : SourceExprCommand
auto pathS = store->printStorePath(node.path); auto pathS = store->printStorePath(node.path);
assert(node.dist != inf); assert(node.dist != inf);
logger->stdout_("%s%s%s%s" ANSI_NORMAL, logger->cout("%s%s%s%s" ANSI_NORMAL,
firstPad, firstPad,
node.visited ? "\e[38;5;244m" : "", node.visited ? "\e[38;5;244m" : "",
firstPad != "" ? "" : "", firstPad != "" ? "" : "",