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.
(cherry picked from commit 408c2faf93
)
# Conflicts:
# src/nix/hash.cc
This commit is contained in:
parent
dd79a490bf
commit
6a8e9736e0
1 changed files with 11 additions and 2 deletions
|
@ -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,8 +184,14 @@ struct CmdToBase : Command
|
|||
|
||||
void run() override
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
warn("The old format conversion sub commands of `nix hash` were deprecated in favor of `nix hash convert`.");
|
||||
for (auto s : args)
|
||||
=======
|
||||
if (!legacyCli)
|
||||
warn("The old format conversion subcommands of `nix hash` were deprecated in favor of `nix hash convert`.");
|
||||
for (const auto & s : args)
|
||||
>>>>>>> 408c2faf9 (nix hash: Don't print 'nix hash' deprecation message)
|
||||
logger->cout(Hash::parseAny(s, hashAlgo).to_string(hashFormat, hashFormat == HashFormat::SRI));
|
||||
}
|
||||
};
|
||||
|
@ -328,7 +337,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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue