Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed

- Fix alignment of doc text of positional arguments (#21)
- Print repeated positional argument docs below fixed positionalargument docs

## 0.8.2

Expand Down
32 changes: 18 additions & 14 deletions src/climate/help.ml
Original file line number Diff line number Diff line change
Expand Up @@ -201,20 +201,24 @@ module Positional_args = struct

let to_print_section { fixed; repeated } =
let entries =
List.map fixed ~f:(fun { Command_doc_spec.Positional_arg.value; doc } ->
{ Print.Entry.names = Print.Names.empty
; value = Some value
; doc
; repeated = false
})
|> List.append
(Option.map repeated ~f:(fun { Command_doc_spec.Positional_arg.value; doc } ->
{ Print.Entry.names = Print.Names.empty
; value = Some value
; doc
; repeated = true
})
|> Option.to_list)
let fixed =
List.map fixed ~f:(fun { Command_doc_spec.Positional_arg.value; doc } ->
{ Print.Entry.names = Print.Names.empty
; value = Some value
; doc
; repeated = false
})
in
let repeated =
Option.map repeated ~f:(fun { Command_doc_spec.Positional_arg.value; doc } ->
{ Print.Entry.names = Print.Names.empty
; value = Some value
; doc
; repeated = true
})
|> Option.to_list
in
fixed @ repeated
in
{ Print.Section.section_heading = "Arguments:"; entries }
;;
Expand Down
2 changes: 1 addition & 1 deletion tests/usage_tests/help_messages.ml
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,9 @@ let%expect_test "positional arguments" =
Usage: foo.exe [OPTION]… <FIRST> <SECOND> [REST]…

Arguments:
[REST]... rest doc
<FIRST> first doc
<SECOND> second doc
[REST]... rest doc

Options:
-h, --help Show this help message.
Expand Down
Loading