You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adjust so it does not throw syntax errors and works for at least some
sampled `.fish` files.
Related #968, #258, #256
---
Sample `abook`:
```nushell
nu ❯ rm abook.nu -f; build-completion abook.fish abook.nu; open abook.nu
# Show usage
extern "abook" [
--add-email # Read email message from stdin and add the sender
--add-email-quiet # Same as --add-email. Without confirmation
--convert # Convert address book files
--informat # Input file format
--outformat # Output file format
--formats # Print available formats
...args
]
```
build-string""$subcommand.name# sub command if present
102
-
}) $quote" [\n" (
103
-
$fishes
104
-
|if ('n'in ($in|columns)) {
105
-
if ($subcommand.name!="") {
106
-
where ($it.n|str contains$subcommand.name) # for subcommand -> any where n matches `__fish_seen_subcommand_from arg` for the subcommand name
107
-
} else {
108
-
where ($it.n=="__fish_use_subcommand") and ($it.a=="") # for root command -> any where n == __fish_use_subcommand and a is empty. otherwise a means a subcommand
109
-
}
110
-
} else {
111
-
$fishes# catch all
112
-
}
113
-
|build-flags
114
-
|str join"\n"
115
-
) "\n\t...args\n]"
98
+
[
99
+
# description
100
+
(if ('d'in ($subcommand.args|columns)) and ($subcommand.args.d!="") { $"# ($subcommand.args.d.0)\n" })
where ($it.n|str contains$subcommand.name) # for subcommand -> any where n matches `__fish_seen_subcommand_from arg` for the subcommand name
110
+
} else {
111
+
where ($it.n=="__fish_use_subcommand") and ($it.a=="") # for root command -> any where n == __fish_use_subcommand and a is empty. otherwise a means a subcommand
112
+
}
113
+
} else {
114
+
$fishes# catch all
115
+
}
116
+
|build-flags
117
+
|str join"\n"
118
+
)
119
+
"\n\t...args"
120
+
"\n]"
121
+
]
122
+
|str join
116
123
}
117
124
}
118
125
119
126
# build the list of flag string in nu syntax
127
+
# record<c, n, a, d, o> -> list<string>
120
128
defbuild-flags [] {
121
-
each { |subargs|
129
+
$in
130
+
|each { |subargs|
122
131
if ('l'in ($subargs|columns)) and ($subargs.l!="") {
123
-
build-string"\t--"$subargs.l (build-string
124
-
(if ('s'in ($subargs|columns)) and ($subargs.s!="") {
125
-
build-string"(-"$subargs.s")"
126
-
}) (if ('d'in ($subargs|columns)) and ($subargs.d!="") {
0 commit comments