mirror of
https://github.com/NixOS/nix
synced 2025-07-07 10:11:47 +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;
|
HashFormat hashFormat;
|
||||||
std::optional<HashAlgorithm> hashAlgo;
|
std::optional<HashAlgorithm> hashAlgo;
|
||||||
std::vector<std::string> args;
|
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));
|
addFlag(flag::hashAlgoOpt("type", &hashAlgo));
|
||||||
expectArgs("strings", &args);
|
expectArgs("strings", &args);
|
||||||
|
@ -181,8 +184,14 @@ struct CmdToBase : Command
|
||||||
|
|
||||||
void run() override
|
void run() override
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
warn("The old format conversion sub commands of `nix hash` were deprecated in favor of `nix hash convert`.");
|
warn("The old format conversion sub commands of `nix hash` were deprecated in favor of `nix hash convert`.");
|
||||||
for (auto s : args)
|
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));
|
logger->cout(Hash::parseAny(s, hashAlgo).to_string(hashFormat, hashFormat == HashFormat::SRI));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -328,7 +337,7 @@ static int compatNixHash(int argc, char * * argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
CmdToBase cmd(hashFormat);
|
CmdToBase cmd(hashFormat, true);
|
||||||
cmd.args = ss;
|
cmd.args = ss;
|
||||||
if (hashAlgo.has_value()) cmd.hashAlgo = hashAlgo;
|
if (hashAlgo.has_value()) cmd.hashAlgo = hashAlgo;
|
||||||
cmd.run();
|
cmd.run();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue