Skip to content

Commit d079886

Browse files
authored
make_docs.nu: fix flags code to only add short_flag when needed (#1658)
* `make_docs.nu`: fix flags code to only add `short_flag` when needed * run `make_docs.nu` * Revert "run `make_docs.nu`" This reverts commit ffbe438, since I didn't want that as part of the PR and just wanted it so people can see the results of running `make_docs.nu` --------- Co-authored-by: Paulie Peña <[email protected]>
1 parent 802df63 commit d079886

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

make_docs.nu

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,14 @@ def command-doc [command] {
169169

170170
let flags = if $no_flags { '' } else {
171171
($command.signatures | get $columns.0 | each { |param|
172-
if $param.parameter_type == "switch" {
173-
$" - `--($param.parameter_name), -($param.short_flag)`: ($param.description)"
174-
} else if $param.parameter_type == "named" {
175-
$" - `--($param.parameter_name), -($param.short_flag) {($param.syntax_shape)}`: ($param.description)"
176-
}
172+
let start = $' - `--($param.parameter_name)'
173+
let end = $'`: ($param.description)'
174+
let short_flag = (if ($param.short_flag | is-empty) {''} else {$', -($param.short_flag)'})
175+
if $param.parameter_type == 'switch' {
176+
$'($start)($short_flag)($end)'
177+
} else if $param.parameter_type == 'named' {
178+
$'($start)($short_flag) {($param.syntax_shape)}($end)'
179+
}
177180
} | str join (char newline))
178181
}
179182

0 commit comments

Comments
 (0)