@@ -252,6 +252,14 @@ def flatten_bitbake_configs(configs):
flattened_configs.append(merge_configs(c, sub_c))
return flattened_configs
+def get_user_input(prompt):
+ choice_s = ''
+ while choice_s.isdigit() == False:
+ print("\n{}:".format(prompt))
+ choice_s = input()
+ choice_n = int(choice_s)
+ return choice_n
+
def choose_bitbake_config(configs, parameters, non_interactive):
flattened_configs = flatten_bitbake_configs(configs)
configs_dict = {i["name"]:i for i in flattened_configs}
@@ -274,8 +282,7 @@ def choose_bitbake_config(configs, parameters, non_interactive):
print("\nAvailable bitbake configurations:")
for n, config_data in enumerated_configs:
print("{}. {}\t{}".format(n, config_data["name"], config_data["description"]))
- print("\nPlease select one of the above bitbake configurations by its number:")
- config_n = int(input())
+ config_n = get_user_input('Please select one of the above bitbake configurations by its number')
return flattened_configs[config_n]
def choose_config(configs, non_interactive):
@@ -298,8 +305,7 @@ def choose_config(configs, non_interactive):
print("{}. {}\t{} (supported until {})".format(n, config_name, config_desc, expiry_date))
else:
print("{}. {}\t{}".format(n, config_name, config_desc))
- print("\nPlease select one of the above configurations by its number:")
- config_n = int(input())
+ config_n = get_user_input('Please select one of the above configurations by its number')
return config_list[config_n][1]
def choose_fragments(possibilities, parameters, non_interactive):
@@ -317,10 +323,16 @@ def choose_fragments(possibilities, parameters, non_interactive):
print("\n" + v["description"] + ":")
options_enumerated = list(enumerate(v["options"]))
+
+ if len(options_enumerated) == 1:
+ only_config = options_enumerated[0]
+ print("\nSelecting the only available option {}".format(only_config))
+ choices[k] = options_enumerated[only_config[0]][1]
+ continue
+
for n,o in options_enumerated:
print("{}. {}".format(n, o))
- print("\nPlease select one of the above options by its number:")
- option_n = int(input())
+ option_n = get_user_input('Please select one of the above options by its number')
choices[k] = options_enumerated[option_n][1]
return choices
Create a common function to get the user input when choosing an item from a list. Add support for not returning from the function until the user has selected a number. When choosing items from the option list, if there is only one item, then auto select it. This is similar to code when picking the configuration. Signed-off-by: Ryan Eatmon <reatmon@ti.com> --- bin/bitbake-setup | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)