mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Add --arg-from-stdin to read an argument from stdin
This commit is contained in:
parent
291b10c607
commit
8ce1f6800b
3 changed files with 16 additions and 1 deletions
|
@ -40,6 +40,14 @@ MixEvalArgs::MixEvalArgs()
|
|||
.completer = completePath
|
||||
});
|
||||
|
||||
addFlag({
|
||||
.longName = "arg-from-stdin",
|
||||
.description = "Pass the contents of stdin as the argument *name* to Nix functions.",
|
||||
.category = category,
|
||||
.labels = {"name"},
|
||||
.handler = {[&](std::string name) { autoArgs.insert_or_assign(name, AutoArg{AutoArgStdin{}}); }},
|
||||
});
|
||||
|
||||
addFlag({
|
||||
.longName = "include",
|
||||
.shortName = 'I',
|
||||
|
@ -174,6 +182,9 @@ Bindings * MixEvalArgs::getAutoArgs(EvalState & state)
|
|||
},
|
||||
[&](const AutoArgFile & arg) {
|
||||
v->mkString(readFile(arg.path));
|
||||
},
|
||||
[&](const AutoArgStdin & arg) {
|
||||
v->mkString(readFile(STDIN_FILENO));
|
||||
}
|
||||
}, arg);
|
||||
res.insert(state.symbols.create(name), v);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue