forked from lix-project/lix
Use Logger::stdout()
This commit is contained in:
parent
696c026006
commit
8f41847394
|
@ -50,7 +50,7 @@ struct CmdAddToStore : MixDryRun, StoreCommand
|
|||
if (!dryRun)
|
||||
store->addToStore(info, sink.s);
|
||||
|
||||
std::cout << fmt("%s\n", store->printStorePath(info.path));
|
||||
logger->stdout("%s", store->printStorePath(info.path));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -55,16 +55,15 @@ struct CmdEval : MixJSON, InstallableCommand
|
|||
auto v = installable->toValue(*state).first;
|
||||
PathSet context;
|
||||
|
||||
stopProgressBar();
|
||||
|
||||
if (raw) {
|
||||
stopProgressBar();
|
||||
std::cout << state->coerceToString(noPos, *v, context);
|
||||
} else if (json) {
|
||||
JSONPlaceholder jsonOut(std::cout);
|
||||
printValueAsJSON(*state, true, *v, jsonOut, context);
|
||||
} else {
|
||||
state->forceValueDeep(*v);
|
||||
std::cout << *v << "\n";
|
||||
logger->stdout("%s", *v);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "command.hh"
|
||||
#include "common-args.hh"
|
||||
#include "shared.hh"
|
||||
#include "progress-bar.hh"
|
||||
#include "eval.hh"
|
||||
#include "eval-inline.hh"
|
||||
#include "flake/flake.hh"
|
||||
|
@ -61,12 +60,10 @@ struct CmdFlakeList : EvalCommand
|
|||
|
||||
auto registries = getRegistries(store);
|
||||
|
||||
stopProgressBar();
|
||||
|
||||
for (auto & registry : registries) {
|
||||
for (auto & entry : registry->entries) {
|
||||
// FIXME: format nicely
|
||||
std::cout << fmt("%s %s %s\n",
|
||||
logger->stdout("%s %s %s",
|
||||
registry->type == Registry::Flag ? "flags " :
|
||||
registry->type == Registry::User ? "user " :
|
||||
registry->type == Registry::System ? "system" :
|
||||
|
@ -80,17 +77,17 @@ struct CmdFlakeList : EvalCommand
|
|||
|
||||
static void printFlakeInfo(const Store & store, const Flake & flake)
|
||||
{
|
||||
std::cout << fmt("Resolved URL: %s\n", flake.resolvedRef.to_string());
|
||||
std::cout << fmt("Locked URL: %s\n", flake.lockedRef.to_string());
|
||||
logger->stdout("Resolved URL: %s", flake.resolvedRef.to_string());
|
||||
logger->stdout("Locked URL: %s", flake.lockedRef.to_string());
|
||||
if (flake.description)
|
||||
std::cout << fmt("Description: %s\n", *flake.description);
|
||||
std::cout << fmt("Path: %s\n", store.printStorePath(flake.sourceInfo->storePath));
|
||||
logger->stdout("Description: %s", *flake.description);
|
||||
logger->stdout("Path: %s", store.printStorePath(flake.sourceInfo->storePath));
|
||||
if (auto rev = flake.lockedRef.input->getRev())
|
||||
std::cout << fmt("Revision: %s\n", rev->to_string(Base16, false));
|
||||
logger->stdout("Revision: %s", rev->to_string(Base16, false));
|
||||
if (flake.sourceInfo->info.revCount)
|
||||
std::cout << fmt("Revisions: %s\n", *flake.sourceInfo->info.revCount);
|
||||
logger->stdout("Revisions: %s", *flake.sourceInfo->info.revCount);
|
||||
if (flake.sourceInfo->info.lastModified)
|
||||
std::cout << fmt("Last modified: %s\n",
|
||||
logger->stdout("Last modified: %s",
|
||||
std::put_time(std::localtime(&*flake.sourceInfo->info.lastModified), "%F %T"));
|
||||
}
|
||||
|
||||
|
@ -156,11 +153,10 @@ struct CmdFlakeInfo : FlakeCommand, MixJSON
|
|||
void run(nix::ref<nix::Store> store) override
|
||||
{
|
||||
auto flake = getFlake();
|
||||
stopProgressBar();
|
||||
|
||||
if (json) {
|
||||
auto json = flakeToJson(*store, flake);
|
||||
std::cout << json.dump() << std::endl;
|
||||
logger->stdout(json.dump());
|
||||
} else
|
||||
printFlakeInfo(*store, flake);
|
||||
}
|
||||
|
@ -177,12 +173,10 @@ struct CmdFlakeListInputs : FlakeCommand, MixJSON
|
|||
{
|
||||
auto flake = lockFlake();
|
||||
|
||||
stopProgressBar();
|
||||
|
||||
if (json)
|
||||
std::cout << flake.lockFile.toJson() << "\n";
|
||||
logger->stdout(flake.lockFile.toJson());
|
||||
else {
|
||||
std::cout << fmt("%s\n", flake.flake.lockedRef);
|
||||
logger->stdout("%s", flake.flake.lockedRef);
|
||||
|
||||
std::function<void(const Node & node, const std::string & prefix)> recurse;
|
||||
|
||||
|
@ -191,7 +185,7 @@ struct CmdFlakeListInputs : FlakeCommand, MixJSON
|
|||
for (const auto & [i, input] : enumerate(node.inputs)) {
|
||||
//auto tree2 = tree.child(i + 1 == inputs.inputs.size());
|
||||
bool last = i + 1 == node.inputs.size();
|
||||
std::cout << fmt("%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s\n",
|
||||
logger->stdout("%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s",
|
||||
prefix + (last ? treeLast : treeConn), input.first,
|
||||
std::dynamic_pointer_cast<const LockedNode>(input.second)->lockedRef);
|
||||
recurse(*input.second, prefix + (last ? treeNull : treeLine));
|
||||
|
|
|
@ -60,8 +60,7 @@ struct CmdHash : Command
|
|||
|
||||
Hash h = hashSink->finish().first;
|
||||
if (truncate && h.hashSize > 20) h = compressHash(h, 20);
|
||||
std::cout << format("%1%\n") %
|
||||
h.to_string(base, base == SRI);
|
||||
logger->stdout(h.to_string(base, base == SRI));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -95,7 +94,7 @@ struct CmdToBase : Command
|
|||
void run() override
|
||||
{
|
||||
for (auto s : args)
|
||||
std::cout << fmt("%s\n", Hash(s, ht).to_string(base, base == SRI));
|
||||
logger->stdout(Hash(s, ht).to_string(base, base == SRI));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -34,16 +34,14 @@ struct MixLs : virtual Args, MixJSON
|
|||
(st.isExecutable ? "-r-xr-xr-x" : "-r--r--r--") :
|
||||
st.type == FSAccessor::Type::tSymlink ? "lrwxrwxrwx" :
|
||||
"dr-xr-xr-x";
|
||||
std::cout <<
|
||||
(format("%s %20d %s") % tp % st.fileSize % relPath);
|
||||
auto line = fmt("%s %20d %s", tp, st.fileSize, relPath);
|
||||
if (st.type == FSAccessor::Type::tSymlink)
|
||||
std::cout << " -> " << accessor->readLink(curPath)
|
||||
;
|
||||
std::cout << "\n";
|
||||
line += " -> " + accessor->readLink(curPath);
|
||||
logger->stdout(line);
|
||||
if (recursive && st.type == FSAccessor::Type::tDirectory)
|
||||
doPath(st, curPath, relPath, false);
|
||||
} else {
|
||||
std::cout << relPath << "\n";
|
||||
logger->stdout(relPath);
|
||||
if (recursive) {
|
||||
auto st = accessor->stat(curPath);
|
||||
if (st.type == FSAccessor::Type::tDirectory)
|
||||
|
|
|
@ -385,7 +385,7 @@ struct CmdProfileInfo : virtual EvalCommand, virtual StoreCommand, MixDefaultPro
|
|||
|
||||
for (size_t i = 0; i < manifest.elements.size(); ++i) {
|
||||
auto & element(manifest.elements[i]);
|
||||
std::cout << fmt("%d %s %s %s\n", i,
|
||||
logger->stdout("%d %s %s %s", i,
|
||||
element.source ? element.source->originalRef.to_string() + "#" + element.source->attrPath : "-",
|
||||
element.source ? element.source->resolvedRef.to_string() + "#" + element.source->attrPath : "-",
|
||||
concatStringsSep(" ", store->printStorePathSet(element.storePaths)));
|
||||
|
|
|
@ -23,7 +23,7 @@ struct CmdShowConfig : Command, MixJSON
|
|||
std::map<std::string, Config::SettingInfo> settings;
|
||||
globalConfig.getSettings(settings);
|
||||
for (auto & s : settings)
|
||||
std::cout << s.first + " = " + s.second.value + "\n";
|
||||
logger->stdout(s.first + " = " + s.second.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -149,7 +149,7 @@ struct CmdWhyDepends : SourceExprCommand
|
|||
auto pathS = store->printStorePath(node.path);
|
||||
|
||||
assert(node.dist != inf);
|
||||
std::cout << fmt("%s%s%s%s" ANSI_NORMAL "\n",
|
||||
logger->stdout("%s%s%s%s" ANSI_NORMAL,
|
||||
firstPad,
|
||||
node.visited ? "\e[38;5;244m" : "",
|
||||
firstPad != "" ? "→ " : "",
|
||||
|
|
Loading…
Reference in a new issue