Skip to content

Commit 8b3e70c

Browse files
committed
Save closure to reuse.
1 parent af653c1 commit 8b3e70c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

custom-completions/uv/uv-completions.nu

+3-2
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ module completions {
131131
let dg = try { open $file | get -i dependency-groups } catch { [] }
132132
# One group can include other groups, like:
133133
# dev = ['click', { include-group = "docs" }, { include-group = "linting" }, { include-group = "test" }]
134+
let handle_line = {|p| if (($p | describe) == 'string') { $p } else { $dg | get ($p.include-group) } }
134135
if ($only_group | is-not-empty) {
135-
$dg | get $only_group | each {|p| if (($p | describe) == 'string') { $p } else { $dg | get ($p.include-group) } } | flatten | parse-package-names
136+
$dg | get $only_group | each $handle_line | flatten | parse-package-names
136137
} else {
137-
$dg | items { |gn, pk| $pk | each {|p| if (($p | describe) == 'string') { $p } else { $dg | get ($p.include-group) } } | flatten } | flatten | parse-package-names
138+
$dg | items { |gn, pk| $pk | each $handle_line | flatten } | flatten | parse-package-names
138139
}
139140
}
140141

0 commit comments

Comments
 (0)