Skip to content

Commit

Permalink
nix hash: Don't print 'nix hash' deprecation message
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Dec 5, 2024
1 parent 33b645c commit 408c2fa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/nix/hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,11 @@ struct CmdToBase : Command
HashFormat hashFormat;
std::optional<HashAlgorithm> hashAlgo;
std::vector<std::string> args;
bool legacyCli;

CmdToBase(HashFormat hashFormat) : hashFormat(hashFormat)
CmdToBase(HashFormat hashFormat, bool legacyCli = false)
: hashFormat(hashFormat)
, legacyCli(legacyCli)
{
addFlag(flag::hashAlgoOpt("type", &hashAlgo));
expectArgs("strings", &args);
Expand All @@ -181,7 +184,8 @@ struct CmdToBase : Command

void run() override
{
warn("The old format conversion sub commands of `nix hash` were deprecated in favor of `nix hash convert`.");
if (!legacyCli)
warn("The old format conversion subcommands of `nix hash` were deprecated in favor of `nix hash convert`.");
for (const auto & s : args)
logger->cout(Hash::parseAny(s, hashAlgo).to_string(hashFormat, hashFormat == HashFormat::SRI));
}
Expand Down Expand Up @@ -328,7 +332,7 @@ static int compatNixHash(int argc, char * * argv)
}

else {
CmdToBase cmd(hashFormat);
CmdToBase cmd(hashFormat, true);
cmd.args = ss;
if (hashAlgo.has_value()) cmd.hashAlgo = hashAlgo;
cmd.run();
Expand Down

0 comments on commit 408c2fa

Please sign in to comment.