diff mbox series

[bitbake-devel] bitbake-setup: Prompt setup directory name

Message ID 20251111172522.2838760-1-JPEWhacker@gmail.com
State New
Headers show
Series [bitbake-devel] bitbake-setup: Prompt setup directory name | expand

Commit Message

Joshua Watt Nov. 11, 2025, 5:25 p.m. UTC
If the setup directory is not specified on the command line, prompt the
user if they would like to change it. This allows the user to use an
alternative name (e.g. a terser one) at setup time.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 bin/bitbake-setup | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Alexander Kanavin Nov. 12, 2025, 6:39 a.m. UTC | #1
On Tue, 11 Nov 2025 at 18:25, Joshua Watt via lists.openembedded.org
<JPEWhacker=gmail.com@lists.openembedded.org> wrote:
> +            n = input(f"Enter setup directory name, or 'N' to quit ({setup_dir_name}): ")

Isn't the convention to put the default in [ ] in such interactive
prompts? Otherwise it is not clear that hitting enter will proceed
with the default.

I'd also not special-case N, one can hit ctrl-c to stop rather (and
that could be hinted).

Alex
Joshua Watt Nov. 12, 2025, 3:19 p.m. UTC | #2
On Tue, Nov 11, 2025 at 11:39 PM Alexander Kanavin
<alex.kanavin@gmail.com> wrote:
>
> On Tue, 11 Nov 2025 at 18:25, Joshua Watt via lists.openembedded.org
> <JPEWhacker=gmail.com@lists.openembedded.org> wrote:
> > +            n = input(f"Enter setup directory name, or 'N' to quit ({setup_dir_name}): ")
>
> Isn't the convention to put the default in [ ] in such interactive
> prompts? Otherwise it is not clear that hitting enter will proceed
> with the default.

You are correct, I thought is was ( ) for some reason. I'll send a V2

>
> I'd also not special-case N, one can hit ctrl-c to stop rather (and
> that could be hinted).
>
> Alex
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index c32381e50..86c556944 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -466,7 +466,18 @@  def init_config(top_dir, settings, args, d):
     upstream_config = obtain_config(top_dir, settings, args, source_overrides, d)
     print("\nRun 'bitbake-setup init --non-interactive {}' to select this configuration non-interactively.\n".format(" ".join(upstream_config['non-interactive-cmdline-options'])))
 
-    setupdir = os.path.join(os.path.abspath(top_dir), args.setup_dir_name or "{}-{}".format(upstream_config['name']," ".join(upstream_config['non-interactive-cmdline-options'][1:]).replace(" ","-").replace("/","_")))
+    if args.setup_dir_name:
+        setup_dir_name = args.setup_dir_name
+    else:
+        setup_dir_name = "{}-{}".format(upstream_config['name']," ".join(upstream_config['non-interactive-cmdline-options'][1:]).replace(" ","-").replace("/","_"))
+        if not args.non_interactive:
+            n = input(f"Enter setup directory name, or 'N' to quit ({setup_dir_name}): ")
+            if n == 'N':
+                exit()
+            elif n:
+                setup_dir_name = n
+
+    setupdir = os.path.join(os.path.abspath(top_dir), setup_dir_name)
     if os.path.exists(os.path.join(setupdir, "layers")):
         print(f"Setup already initialized in:\n    {setupdir}\nUse 'bitbake-setup status' to check if it needs to be updated, or 'bitbake-setup update' to perform the update.\nIf you would like to start over and re-initialize in this directory, remove it, and run 'bitbake-setup init' again.")
         return