mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 15:26:17 +02: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
1 changed files with 6 additions and 16 deletions
|
@ -53,24 +53,14 @@ nix-prefetch-url --help
|
|||
function subcommands() {
|
||||
jq -r '
|
||||
def recurse($prefix):
|
||||
if .commands then
|
||||
.commands | to_entries[] | .key as $k |
|
||||
($prefix + " " + $k) as $newPrefix |
|
||||
if .value | has("commands") then
|
||||
(.value | recurse($newPrefix))
|
||||
to_entries[] |
|
||||
($prefix + [.key]) as $newPrefix |
|
||||
(if .value | has("commands") then
|
||||
($newPrefix, (.value.commands | recurse($newPrefix)))
|
||||
else
|
||||
$newPrefix
|
||||
end
|
||||
else
|
||||
$prefix
|
||||
end;
|
||||
|
||||
.args.commands | to_entries[] | .key as $cmd |
|
||||
if .value | has("commands") then
|
||||
(.value | recurse($cmd))
|
||||
else
|
||||
$cmd
|
||||
end
|
||||
end);
|
||||
.args.commands | recurse([]) | join(" ")
|
||||
'
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue