Fix input reading, banner touch up

pull/195/head v3.0.0-rc5
Šimon Let 3 years ago
parent a692aae582
commit e076add109
  1. 20
      internal/device/device.go
  2. 10
      scripts/install.sh

@ -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
}

@ -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

Loading…
Cancel
Save