mirror of
https://github.com/NixOS/nix
synced 2025-07-07 10:11:47 +02:00
parent
33b645cedf
commit
408c2faf93
1 changed files with 7 additions and 3 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,7 +184,8 @@ struct CmdToBase : Command
|
||||||
|
|
||||||
void run() override
|
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)
|
for (const auto & s : args)
|
||||||
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 +332,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