From e076add109c15561ef74c483669b395254473c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Let?= Date: Sat, 25 Mar 2023 23:16:41 +0100 Subject: [PATCH] Fix input reading, banner touch up --- internal/device/device.go | 20 +++++++++----------- scripts/install.sh | 10 +++++----- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/internal/device/device.go b/internal/device/device.go index 1e9fdab9..7c04f6fc 100644 --- a/internal/device/device.go +++ b/internal/device/device.go @@ -126,20 +126,18 @@ func promptForName(out *output.Output, fpath string) (string, error) { return "", fmt.Errorf("could not get hostname (prompt default): %w", err) } hostStub := strings.Split(host, ".")[0] - fmt.Printf("\nPlease choose a short name for this device (default: '%s'): ", hostStub) - var input string - scanner := bufio.NewScanner(os.Stdin) - if scanner.Scan() { - input = scanner.Text() - } - if err = scanner.Err(); err != nil { - return "", fmt.Errorf("scanner error: %w", err) + reader := bufio.NewReader(os.Stdin) + fmt.Printf("\nChoose a short name for this device (default: '%s'): ", hostStub) + input, err := reader.ReadString('\n') + name := strings.TrimRight(input, "\n") + if err != nil { + return "", fmt.Errorf("reader error: %w", err) } - if input == "" { + if name == "" { out.Info("Got no input - using default ...") - input = hostStub + name = hostStub } - out.Info(fmt.Sprintf("Device name set to '%s'", input)) + out.Info(fmt.Sprintf("Device name set to '%s'", name)) fmt.Printf("You can change the device name at any time by editing '%s' file\n", fpath) return input, nil } diff --git a/scripts/install.sh b/scripts/install.sh index 16c733cf..83569b87 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -187,10 +187,10 @@ printf ' # Show banner if RESH is not loaded in the terminal if [ -z "${__RESH_VERSION-}" ]; then printf ' -############################################################## -# # -# Finish the installation by RESTARTING this terminal! # -# # -############################################################## +┌────────────────────────────────────────────────────────────┐ +│ │ +│ Finish the installation by RESTARTING this terminal! │ +│ │ +└────────────────────────────────────────────────────────────┘ ' fi