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

Merge pull request #9822 from obsidiansystems/algo-vs-hash-algo

Start standardizing hash algo flags
This commit is contained in:
Théophane Hufschmitt 2024-01-22 11:08:24 +01:00 committed by GitHub
commit c8d33bca8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 30 additions and 24 deletions

View file

@ -177,7 +177,13 @@ protected:
std::optional<ExperimentalFeature> experimentalFeature;
static Flag mkHashAlgoFlag(std::string && longName, HashAlgorithm * ha);
static Flag mkHashAlgoFlag(HashAlgorithm * ha) {
return mkHashAlgoFlag("hash-algo", ha);
}
static Flag mkHashAlgoOptFlag(std::string && longName, std::optional<HashAlgorithm> * oha);
static Flag mkHashAlgoOptFlag(std::optional<HashAlgorithm> * oha) {
return mkHashAlgoOptFlag("hash-algo", oha);
}
static Flag mkHashFormatFlagWithDefault(std::string && longName, HashFormat * hf);
static Flag mkHashFormatOptFlag(std::string && longName, std::optional<HashFormat> * ohf);
};

View file

@ -53,7 +53,7 @@ struct CmdAddToStore : MixDryRun, StoreCommand
}},
});
addFlag(Flag::mkHashAlgoFlag("hash-algo", &hashAlgo));
addFlag(Flag::mkHashAlgoFlag(&hashAlgo));
}
void run(ref<Store> store) override

View file

@ -141,7 +141,7 @@ struct CmdHashConvert : Command
CmdHashConvert(): to(HashFormat::SRI) {
addFlag(Args::Flag::mkHashFormatOptFlag("from", &from));
addFlag(Args::Flag::mkHashFormatFlagWithDefault("to", &to));
addFlag(Args::Flag::mkHashAlgoOptFlag("algo", &algo));
addFlag(Args::Flag::mkHashAlgoOptFlag(&algo));
expectArgs({
.label = "hashes",
.handler = {&hashStrings},