Skip to content

Commit c312bf0

Browse files
committed
fishgen: Fix flags crossing subcommands
1 parent f371420 commit c312bf0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

needs-update/custom-completions/auto-generate/parse-fish.nu

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def build-completions-from-pwd [] {
1313

1414
# build a completion form a .fish file and generate a .nu file
1515
def build-completion [fish_file: path, nu_file: path] {
16-
open $fish_file | parse-fish | make-commands-completion | str join "\n\n" | save $nu_file
16+
open $fish_file | parse-fish | make-commands-completion | str join "\n\n" | save $nu_file -f
1717
}
1818

1919
# parse a .fish file based on autogenerated complete syntax
@@ -78,6 +78,7 @@ def make-commands-completion [] {
7878
| get c # c is the command name
7979
| uniq # is cloned on every complete line
8080
| each { |command|
81+
print $'COMMAND ($command)'
8182
$fishes | where c == $command | make-subcommands-completion [$command]
8283
| str join "\n\n"
8384
}
@@ -94,6 +95,7 @@ def make-subcommands-completion [parents: list<string>] {
9495
| group-by a # group by sub command (a flag)
9596
| transpose name args # turn it into a table of name to arguments
9697
| each {|subcommand|
98+
print $'SUBCOMMAND ($subcommand.name) ($subcommand.args | length)'
9799
[
98100
# description
99101
(if ('d' in ($subcommand.args | columns)) and ($subcommand.args.d != "") { $"# ($subcommand.args.d.0)\n" })
@@ -103,7 +105,7 @@ def make-subcommands-completion [parents: list<string>] {
103105
" [\n"
104106
(
105107
$fishes
106-
| if ('n' in ($subcommand | columns)) {
108+
| if ('n' in ($subcommand.args | columns)) {
107109
if ($subcommand.name != "") {
108110
where ($it.n | str contains $subcommand.name) # for subcommand -> any where n matches `__fish_seen_subcommand_from arg` for the subcommand name
109111
} else {

0 commit comments

Comments
 (0)