1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 21:41:48 +02:00

nix hash: Don't print 'nix hash' deprecation message

Fixes #11997.
This commit is contained in:
Eelco Dolstra 2024-12-05 16:25:05 +01:00
parent 33b645cedf
commit 408c2faf93

View file

@ -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);
@ -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));
}
@ -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();