forked from lix-project/lix
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
2 changed files with 15 additions and 0 deletions
|
@ -54,6 +54,11 @@ have an effect.
|
||||||
created by sequentially numbering symlinks beyond the first one
|
created by sequentially numbering symlinks beyond the first one
|
||||||
(e.g., `foo`, `foo-2`, `foo-3`, and so on).
|
(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`
|
# Operation `--realise`
|
||||||
|
|
||||||
## Synopsis
|
## Synopsis
|
||||||
|
|
|
@ -1020,6 +1020,7 @@ static int main_nix_store(int argc, char * * argv)
|
||||||
{
|
{
|
||||||
Strings opFlags, opArgs;
|
Strings opFlags, opArgs;
|
||||||
Operation op = 0;
|
Operation op = 0;
|
||||||
|
bool readFromStdIn;
|
||||||
|
|
||||||
parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||||
Operation oldOp = op;
|
Operation oldOp = op;
|
||||||
|
@ -1078,6 +1079,8 @@ static int main_nix_store(int argc, char * * argv)
|
||||||
op = opGenerateBinaryCacheKey;
|
op = opGenerateBinaryCacheKey;
|
||||||
else if (*arg == "--add-root")
|
else if (*arg == "--add-root")
|
||||||
gcRoot = absPath(getArg(*arg, arg, end));
|
gcRoot = absPath(getArg(*arg, arg, end));
|
||||||
|
else if (*arg == "--stdin" && !isatty(STDIN_FILENO))
|
||||||
|
readFromStdIn = true;
|
||||||
else if (*arg == "--indirect")
|
else if (*arg == "--indirect")
|
||||||
;
|
;
|
||||||
else if (*arg == "--no-output")
|
else if (*arg == "--no-output")
|
||||||
|
@ -1090,6 +1093,13 @@ static int main_nix_store(int argc, char * * argv)
|
||||||
else
|
else
|
||||||
opArgs.push_back(*arg);
|
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)
|
if (oldOp && oldOp != op)
|
||||||
throw UsageError("only one operation may be specified");
|
throw UsageError("only one operation may be specified");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue