mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 06:42:28 +00:00
less scary jq
Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
This commit is contained in:
parent
4b15ca2ffb
commit
8a6ef3bae5
@ -53,24 +53,14 @@ nix-prefetch-url --help
|
|||||||
function subcommands() {
|
function subcommands() {
|
||||||
jq -r '
|
jq -r '
|
||||||
def recurse($prefix):
|
def recurse($prefix):
|
||||||
if .commands then
|
to_entries[] |
|
||||||
.commands | to_entries[] | .key as $k |
|
($prefix + [.key]) as $newPrefix |
|
||||||
($prefix + " " + $k) as $newPrefix |
|
(if .value | has("commands") then
|
||||||
if .value | has("commands") then
|
($newPrefix, (.value.commands | recurse($newPrefix)))
|
||||||
(.value | recurse($newPrefix))
|
|
||||||
else
|
else
|
||||||
$newPrefix
|
$newPrefix
|
||||||
end
|
end);
|
||||||
else
|
.args.commands | recurse([]) | join(" ")
|
||||||
$prefix
|
|
||||||
end;
|
|
||||||
|
|
||||||
.args.commands | to_entries[] | .key as $cmd |
|
|
||||||
if .value | has("commands") then
|
|
||||||
(.value | recurse($cmd))
|
|
||||||
else
|
|
||||||
$cmd
|
|
||||||
end
|
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user