Improve 'nix flake info' a bit

Example:

  $ nix flake info dwarffs
  ID:          dwarffs
  URI:         github:edolstra/dwarffs/a83d182fe3fe528ed6366a5cec3458bcb1a5f6e1
  Description: A filesystem that fetches DWARF debug info from the Internet on demand
  Revision:    a83d182fe3fe528ed6366a5cec3458bcb1a5f6e1
  Path:        /nix/store/grgd14kxxk8q4n503j87mpz48gcqpqw7-source
This commit is contained in:
Eelco Dolstra 2019-04-16 16:18:03 +02:00
parent 54ca4b4e81
commit 3c28cb1b8f

View file

@ -40,13 +40,19 @@ void printFlakeInfo(Flake & flake, bool json) {
if (json) {
nlohmann::json j;
j["id"] = flake.id;
j["location"] = flake.sourceInfo.storePath;
j["uri"] = flake.sourceInfo.flakeRef.to_string();
j["description"] = flake.description;
if (flake.sourceInfo.rev)
j["revision"] = flake.sourceInfo.rev->to_string(Base16, false);
j["path"] = flake.sourceInfo.storePath;
std::cout << j.dump(4) << std::endl;
} else {
std::cout << "ID: " << flake.id << "\n";
std::cout << "URI: " << flake.sourceInfo.flakeRef.to_string() << "\n";
std::cout << "Description: " << flake.description << "\n";
std::cout << "Location: " << flake.sourceInfo.storePath << "\n";
if (flake.sourceInfo.rev)
std::cout << "Revision: " << flake.sourceInfo.rev->to_string(Base16, false) << "\n";
std::cout << "Path: " << flake.sourceInfo.storePath << "\n";
}
}