bitbake-setup: improve consistency in prompts
cover bitbake-setup: improve consistency in prompts
The prompts for integer inputs are displaying the user input after the line while string inputs are displaying the user input next to the prompt. This aligns the behavior to have the user input next to the prompt in all cases, even for numbers, even for retries.
This also fixes what could be said to be a typo: the colon was added before the default value for one prompt instead of after, confusing me a bit as to what was expected from me.
---
Quentin Schulz (3):
bitbake-setup: allow to pass a prompt to int_input
bitbake-setup: make all callers of int_input pass their prompt
bitbake-setup: put colon of prompt after suggested default
bin/bitbake-setup | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
---
base-commit: 720df1a53452983c1c832f624490e255cf389204
change-id: 20251203-bitbake-setup-input-consistent-1186fa1d45a3
Best regards,
Signature · 1 line
Quentin Schulz <[email protected]>
PATCH 1/3 bitbake-setup: allow to pass a prompt to int_input
From: Quentin Schulz <[email protected]>
This will allow us to have consistency between expected user inputs by having them all doing something along the lines of:
Type number: 2
instead of
Type number:
2
This migrates the retry prompts to use that new mechanism.
--- bin/bitbake-setup | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
bin/bitbake-setup +4 -4
@@ -330,16 +330,16 @@ def update_build(config, confdir, setupdir, layerdir, d, update_bb_conf="prompt" setup_bitbake_build(bitbake_config, layerdir, setupdir, thisdir, update_bb_conf) write_sources_fixed_revisions(confdir, sources_fixed_revisions) -def int_input(allowed_values): +def int_input(allowed_values, prompt=''): n = None while n is None: try: - n = int(input()) + n = int(input(prompt)) except ValueError: - print('Not a valid number, please try again:') + prompt = 'Not a valid number, please try again: ' continue if n not in allowed_values: - print('Number {} not one of {}, please try again:'.format(n, allowed_values)) + prompt = 'Number {} not one of {}, please try again: '.format(n, allowed_values) n = None return n
Signature · 1 line
2.52.0
PATCH 2/3 bitbake-setup: make all callers of int_input pass their prompt
In reply to Quentin SchulzFrom: Quentin Schulz <[email protected]>
This aligns the behavior of int_input() with input() so that the user input is printed on the same line as the prompt.
--- bin/bitbake-setup | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
bin/bitbake-setup +6 -6
@@ -388,8 +388,8 @@ 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([i[0] for i in enumerated_configs]) - 1 + config_n = int_input([i[0] for i in enumerated_configs], + "\nPlease select one of the above bitbake configurations by its number: ") - 1 return flattened_configs[config_n] def choose_config(configs, non_interactive):
@@ -412,8 +412,8 @@ 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([i[0] for i in config_list]) - 1 + config_n = int_input([i[0] for i in config_list], + "\nPlease select one of the above configurations by its number: ") - 1 return config_list[config_n][1] def choose_fragments(possibilities, parameters, non_interactive, skip_selection):
@@ -436,8 +436,8 @@ def choose_fragments(possibilities, parameters, non_interactive, skip_selection) options_enumerated = list(enumerate(v["options"], 1)) 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([i[0] for i in options_enumerated]) - 1 + option_n = int_input([i[0] for i in options_enumerated], + "\nPlease select one of the above options by its number: ") - 1 choices[k] = options_enumerated[option_n][1] return choices
Signature · 1 line
2.52.0
PATCH 3/3 bitbake-setup: put colon of prompt after suggested default
In reply to Quentin SchulzFrom: Quentin Schulz <[email protected]>
Otherwise it differs from other input prompts we have and it's not really clear whether anything is expected from the user.
---
Also wondering if we shouldn't switch to () instead of [] for surrounding the default value if no input is provided by the user
--- bin/bitbake-setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
bin/bitbake-setup +1 -1
@@ -514,7 +514,7 @@ def init_config(top_dir, settings, args): setup_dir_name = config_setup_dir_name if not args.non_interactive: - n = input(f"Enter setup directory name: [{setup_dir_name}] ") + n = input(f"Enter setup directory name [{setup_dir_name}]: ") if n: setup_dir_name = n
Signature · 1 line
2.52.0
Thanks, all three lgtm.
Alex
Quoted 36 lines · Quentin Schulz via lists.openembedded.org
The prompts for integer inputs are displaying the user input after the line while string inputs are displaying the user input next to the prompt. This aligns the behavior to have the user input next to the prompt in all cases, even for numbers, even for retries.
This also fixes what could be said to be a typo: the colon was added before the default value for one prompt instead of after, confusing me a bit as to what was expected from me.
Signed-off-by Quentin Schulz <[email protected]>---
Quentin Schulz (3):
bitbake-setup: allow to pass a prompt toint_input
bitbake-setup: make all callers ofint_inputpass their prompt
bitbake-setup: put colon of prompt after suggested defaultbin/bitbake-setup | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)---
base-commit:720df1a53452983c1c832f624490e255cf389204
change-id: 20251203-bitbake-setup-input-consistent-1186fa1d45a3Best regards,
--
Quentin Schulz <[email protected]>-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#18523): https://lists.openembedded.org/g/bitbake-devel/message/18523
Mute This Topic: https://lists.openembedded.org/mt/116592605/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-