diff --git a/locales/en.json b/locales/en.json index 447f137a5..4572e6f86 100644 --- a/locales/en.json +++ b/locales/en.json @@ -541,6 +541,7 @@ "migrations_to_be_ran_manually": "Migration {id} has to be run manually. Please go to Tools → Migrations on the webadmin page, or run `yunohost tools migrations run`.", "not_enough_disk_space": "Not enough free space on '{path}'", "operation_interrupted": "The operation was manually interrupted?", + "other_available_options": "... and {n} other available options not shown", "packages_upgrade_failed": "Could not upgrade all the packages", "password_listed": "This password is among the most used passwords in the world. Please choose something more unique.", "password_too_simple_1": "The password needs to be at least 8 characters long", diff --git a/src/yunohost/utils/config.py b/src/yunohost/utils/config.py index 7b3d44b57..2b83507f0 100644 --- a/src/yunohost/utils/config.py +++ b/src/yunohost/utils/config.py @@ -566,7 +566,22 @@ class Question(object): ) def _format_text_for_user_input_in_cli(self): - return _value_for_locale(self.ask) + + text_for_user_input_in_cli = _value_for_locale(self.ask) + + if self.choices: + + # Prevent displaying a shitload of choices + # (e.g. 100+ available users when choosing an app admin...) + choices_to_display = self.choices[:20] + remaining_choices = len(self.choices[20:]) + + if remaining_choices > 0: + choices_to_display += [m18n.n("other_available_options", n=remaining_choices)] + + text_for_user_input_in_cli += " [{0}]".format(" | ".join(choices_to_display)) + + return text_for_user_input_in_cli def _post_parse_value(self): if not self.redact: