nix-store: read paths from standard input
Resolves #7437 for new `nix-store` by adding a `--stdin` flag.
This commit is contained in:
parent
269caa5317
commit
df643051e2
|
@ -54,6 +54,11 @@ have an effect.
|
|||
created by sequentially numbering symlinks beyond the first one
|
||||
(e.g., `foo`, `foo-2`, `foo-3`, and so on).
|
||||
|
||||
- <span id="opt-stdin">[`--stdin`](#opt-stdin)</span>
|
||||
|
||||
Read *paths…* from the standard input.
|
||||
Useful for chaining nix-store commands.
|
||||
|
||||
# Operation `--realise`
|
||||
|
||||
## Synopsis
|
||||
|
|
|
@ -1020,6 +1020,7 @@ static int main_nix_store(int argc, char * * argv)
|
|||
{
|
||||
Strings opFlags, opArgs;
|
||||
Operation op = 0;
|
||||
bool readFromStdIn;
|
||||
|
||||
parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
Operation oldOp = op;
|
||||
|
@ -1078,6 +1079,8 @@ static int main_nix_store(int argc, char * * argv)
|
|||
op = opGenerateBinaryCacheKey;
|
||||
else if (*arg == "--add-root")
|
||||
gcRoot = absPath(getArg(*arg, arg, end));
|
||||
else if (*arg == "--stdin" && !isatty(STDIN_FILENO))
|
||||
readFromStdIn = true;
|
||||
else if (*arg == "--indirect")
|
||||
;
|
||||
else if (*arg == "--no-output")
|
||||
|
@ -1090,6 +1093,13 @@ static int main_nix_store(int argc, char * * argv)
|
|||
else
|
||||
opArgs.push_back(*arg);
|
||||
|
||||
if (readFromStdIn && op != opImport && op != opRestore && op != opServe) {
|
||||
std::string word;
|
||||
while (std::cin >> word) {
|
||||
opArgs.emplace_back(std::move(word));
|
||||
};
|
||||
}
|
||||
|
||||
if (oldOp && oldOp != op)
|
||||
throw UsageError("only one operation may be specified");
|
||||
|
||||
|
|
Loading…
Reference in a new issue