Skip to content

Commit b749b7a

Browse files
authored
Merge pull request #5992 from dra27/35-items
Extend OpamConsole.menu to support 35 options
2 parents 5c582e1 + 75f46bc commit b749b7a

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

master_changes.md

+1
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,4 @@ users)
182182
* `OpamStubs.readRegistry`: on Windows, complements `OpamStubs.writeRegistry` [#5963 @dra27]
183183
* `OpamStubs.get_initial_environment`: on Windows, returns the pristine environment for new shells [#5963 @dra27]
184184
* `OpamConsole`: Add `formatted_errmsg` [#5999 @kit-ty-kate]
185+
* `OpamConsole.menu` now supports up to 35 menu items [#5992 @dra27]

src/core/opamConsole.ml

+6-2
Original file line numberDiff line numberDiff line change
@@ -964,9 +964,13 @@ let print_table ?cut oc ~sep table =
964964
List.iter (fun l -> print_line (cleanup_trailing l)) table
965965

966966
let menu ?default ?unsafe_yes ?yes ~no ~options fmt =
967-
assert (List.length options < 10);
967+
assert (List.length options < 36);
968968
let options_nums =
969-
List.mapi (fun n (ans, _) -> ans, string_of_int (n+1)) options
969+
let option_of_index n =
970+
(* NOTE: 1..9 (starts at ASCII 49) & a..z (starts at ASCII 97) *)
971+
(String.make 1 (char_of_int (if n < 9 then n+49 else n+97)))
972+
in
973+
List.mapi (fun n (ans, _) -> ans, option_of_index n) options
970974
in
971975
let nums_options = List.map (fun (a, n) -> n, a) options_nums in
972976
let rec prev_option a0 = function

src/core/opamConsole.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ val confirm:
133133
options are set.
134134
[no] is the option to choose otherwise, when non interactive, on [escape].
135135
[default] is the option to choose on an active empty input ("\n").
136-
Max 9 options. *)
136+
Max 35 options. *)
137137
val menu:
138138
?default:'a -> ?unsafe_yes:'a -> ?yes:'a -> no:'a ->
139139
options:('a * string) list ->

0 commit comments

Comments
 (0)