Skip to content

Commit

Permalink
allow entering allowed input in dub init
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Jan 11, 2023
1 parent 4c72b12 commit 0c582d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion source/dub/commandline.d
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ class InitCommand : Command {
if (option_idx < options.length)
return options[option_idx];
}
else if (free_choice)
else if (free_choice || options.canFind(choice))
return choice;
logError("Select an option between 1 and %u%s.", options.length,
free_choice ? " or enter a custom value" : null);
Expand Down
6 changes: 4 additions & 2 deletions test/0-init-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ function runTest {
runTest '0\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.sdl
# select package format out of bounds
runTest '3\n0\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.sdl
# select package format not numeric
runTest 'sdl\n0\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.sdl
# select package format not numeric, but in list
runTest 'sdl\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.sdl
# selected value not numeric and not in list
runTest 'sdlf\n0\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.sdl
# default name
runTest '0\n\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.default_name.dub.sdl
# json package format
Expand Down

0 comments on commit 0c582d9

Please sign in to comment.