diff mbox series

[bitbake-devel] bitbake-setup: Improve continue prompt

Message ID 20251111173841.2842051-1-JPEWhacker@gmail.com
State New
Headers show
Series [bitbake-devel] bitbake-setup: Improve continue prompt | expand

Commit Message

Joshua Watt Nov. 11, 2025, 5:38 p.m. UTC
Reworks the prompt to continue with the setup wizard in a number of
ways:
 1) Default to 'Y' if the user just hits enter. In general, users are
    more likely to want to continue than they want to exit.
 2) The tools prints "Exiting" when the user doesn't want to continue,
    as a clear indication that the script exited without doing anything.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 bin/bitbake-setup | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

Comments

Yoann Congal Nov. 11, 2025, 9:18 p.m. UTC | #1
Hello,

Le mar. 11 nov. 2025 à 18:38, Joshua Watt via lists.openembedded.org
<JPEWhacker=gmail.com@lists.openembedded.org> a écrit :

> Reworks the prompt to continue with the setup wizard in a number of
> ways:
>  1) Default to 'Y' if the user just hits enter. In general, users are
>     more likely to want to continue than they want to exit.
>

In the absence of Alex, I'd like to remind what he said about defaulting to
No: https://lists.openembedded.org/g/bitbake-devel/message/18113:

> There was some discussion as to whether this should be Y/n (e.g. hit
> Enter to proceed). I'd rather err on the cautious side here, as people
> nowadays have muscle memory to agree and accept with anything and
> everything, and proceed as quickly as possible, they would do it here
> too, without reading what the tool is going to do, and only then
> realize it's not what they wanted.


Personally, I'm slightly in favor of defaulting to Yes: This will make the
experience more fluid for new users and answering Y instead of N is not
that dangerous for bitbake-setup (IIRC, we're not erasing any data just
putting files in an unexpected directory)


>  2) The tools prints "Exiting" when the user doesn't want to continue,
>     as a clear indication that the script exited without doing anything.
>
> Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
> ---
>  bin/bitbake-setup | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/bin/bitbake-setup b/bin/bitbake-setup
> index 282fa82ff..9c6d787bf 100755
> --- a/bin/bitbake-setup
> +++ b/bin/bitbake-setup
> @@ -134,6 +134,14 @@ def checkout_layers(layers, layerdir, d):
>
>      return layers_fixed_revisions
>
> +def prompt_continue(non_interactive):
> +    if not non_interactive:
> +        p = input('Continue? (Y/n): ')
> +        if p and p.lower() != 'y':
> +            print("Exiting")
> +            exit()
> +        print()
> +
>  def setup_bitbake_build(bitbake_config, layerdir, setupdir, thisdir):
>      def _setup_build_conf(layers, filerelative_layers, build_conf_dir):
>          os.makedirs(build_conf_dir)
> @@ -483,11 +491,7 @@ def init_config(top_dir, settings, args, d):
>          return
>
>      print("Initializing a setup directory in\n    {}".format(setupdir))
> -    if not args.non_interactive:
> -        y_or_n = input('Continue? (y/N): ')
> -        if y_or_n != 'y':
> -            exit()
> -        print()
> +    prompt_continue(args.non_interactive)
>
>      os.makedirs(setupdir, exist_ok=True)
>
> @@ -676,10 +680,7 @@ def create_siteconf(top_dir, non_interactive=True):
>          print('A site.conf file already exists. Please remove it if you
> would like to replace it with a default one')
>      else:
>          print('A common site.conf file will be created, please edit or
> replace before running builds\n    {}\n'.format(siteconfpath))
> -        if not non_interactive:
> -            y_or_n = input('Proceed? (y/N): ')
> -            if y_or_n != 'y':
> -                exit()
> +        prompt_continue(non_interactive)
>
>          os.makedirs(os.path.dirname(top_dir), exist_ok=True)
>          with open(siteconfpath, 'w') as siteconffile:
> --
> 2.51.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#18332):
> https://lists.openembedded.org/g/bitbake-devel/message/18332
> Mute This Topic: https://lists.openembedded.org/mt/116242231/4316185
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [
> yoann.congal@smile.fr]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Joshua Watt Nov. 11, 2025, 9:44 p.m. UTC | #2
On Tue, Nov 11, 2025 at 2:18 PM Yoann Congal <yoann.congal@smile.fr> wrote:
>
> Hello,
>
> Le mar. 11 nov. 2025 à 18:38, Joshua Watt via lists.openembedded.org <JPEWhacker=gmail.com@lists.openembedded.org> a écrit :
>>
>> Reworks the prompt to continue with the setup wizard in a number of
>> ways:
>>  1) Default to 'Y' if the user just hits enter. In general, users are
>>     more likely to want to continue than they want to exit.
>
>
> In the absence of Alex, I'd like to remind what he said about defaulting to No: https://lists.openembedded.org/g/bitbake-devel/message/18113:
>>
>> There was some discussion as to whether this should be Y/n (e.g. hit
>> Enter to proceed). I'd rather err on the cautious side here, as people
>> nowadays have muscle memory to agree and accept with anything and
>> everything, and proceed as quickly as possible, they would do it here
>> too, without reading what the tool is going to do, and only then
>> realize it's not what they wanted.
>
>
> Personally, I'm slightly in favor of defaulting to Yes: This will make the experience more fluid for new users and answering Y instead of N is not that dangerous for bitbake-setup (IIRC, we're not erasing any data just putting files in an unexpected directory)

That's fine. If we don't want to merge this I'm not going to argue.

>
>>
>>  2) The tools prints "Exiting" when the user doesn't want to continue,
>>     as a clear indication that the script exited without doing anything.
>>
>> Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
>> ---
>>  bin/bitbake-setup | 19 ++++++++++---------
>>  1 file changed, 10 insertions(+), 9 deletions(-)
>>
>> diff --git a/bin/bitbake-setup b/bin/bitbake-setup
>> index 282fa82ff..9c6d787bf 100755
>> --- a/bin/bitbake-setup
>> +++ b/bin/bitbake-setup
>> @@ -134,6 +134,14 @@ def checkout_layers(layers, layerdir, d):
>>
>>      return layers_fixed_revisions
>>
>> +def prompt_continue(non_interactive):
>> +    if not non_interactive:
>> +        p = input('Continue? (Y/n): ')
>> +        if p and p.lower() != 'y':
>> +            print("Exiting")
>> +            exit()
>> +        print()
>> +
>>  def setup_bitbake_build(bitbake_config, layerdir, setupdir, thisdir):
>>      def _setup_build_conf(layers, filerelative_layers, build_conf_dir):
>>          os.makedirs(build_conf_dir)
>> @@ -483,11 +491,7 @@ def init_config(top_dir, settings, args, d):
>>          return
>>
>>      print("Initializing a setup directory in\n    {}".format(setupdir))
>> -    if not args.non_interactive:
>> -        y_or_n = input('Continue? (y/N): ')
>> -        if y_or_n != 'y':
>> -            exit()
>> -        print()
>> +    prompt_continue(args.non_interactive)
>>
>>      os.makedirs(setupdir, exist_ok=True)
>>
>> @@ -676,10 +680,7 @@ def create_siteconf(top_dir, non_interactive=True):
>>          print('A site.conf file already exists. Please remove it if you would like to replace it with a default one')
>>      else:
>>          print('A common site.conf file will be created, please edit or replace before running builds\n    {}\n'.format(siteconfpath))
>> -        if not non_interactive:
>> -            y_or_n = input('Proceed? (y/N): ')
>> -            if y_or_n != 'y':
>> -                exit()
>> +        prompt_continue(non_interactive)
>>
>>          os.makedirs(os.path.dirname(top_dir), exist_ok=True)
>>          with open(siteconfpath, 'w') as siteconffile:
>> --
>> 2.51.1
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#18332): https://lists.openembedded.org/g/bitbake-devel/message/18332
>> Mute This Topic: https://lists.openembedded.org/mt/116242231/4316185
>> Group Owner: bitbake-devel+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [yoann.congal@smile.fr]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
>
>
> --
> Yoann Congal
> Smile ECS
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index 282fa82ff..9c6d787bf 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -134,6 +134,14 @@  def checkout_layers(layers, layerdir, d):
 
     return layers_fixed_revisions
 
+def prompt_continue(non_interactive):
+    if not non_interactive:
+        p = input('Continue? (Y/n): ')
+        if p and p.lower() != 'y':
+            print("Exiting")
+            exit()
+        print()
+
 def setup_bitbake_build(bitbake_config, layerdir, setupdir, thisdir):
     def _setup_build_conf(layers, filerelative_layers, build_conf_dir):
         os.makedirs(build_conf_dir)
@@ -483,11 +491,7 @@  def init_config(top_dir, settings, args, d):
         return
 
     print("Initializing a setup directory in\n    {}".format(setupdir))
-    if not args.non_interactive:
-        y_or_n = input('Continue? (y/N): ')
-        if y_or_n != 'y':
-            exit()
-        print()
+    prompt_continue(args.non_interactive)
 
     os.makedirs(setupdir, exist_ok=True)
 
@@ -676,10 +680,7 @@  def create_siteconf(top_dir, non_interactive=True):
         print('A site.conf file already exists. Please remove it if you would like to replace it with a default one')
     else:
         print('A common site.conf file will be created, please edit or replace before running builds\n    {}\n'.format(siteconfpath))
-        if not non_interactive:
-            y_or_n = input('Proceed? (y/N): ')
-            if y_or_n != 'y':
-                exit()
+        prompt_continue(non_interactive)
 
         os.makedirs(os.path.dirname(top_dir), exist_ok=True)
         with open(siteconfpath, 'w') as siteconffile: