Allow force lower case commands (Issue #15)

This commit is contained in:
Terence Boldt 2021-09-28 17:34:22 -04:00
parent 18c25108b3
commit 1b184a9b5a

View File

@ -9,6 +9,8 @@ import (
"github.com/tjboldt/Apple2-IO-RPi/RaspberryPi/apple2driver/a2io" "github.com/tjboldt/Apple2-IO-RPi/RaspberryPi/apple2driver/a2io"
) )
var forceLowercase = false
func ExecCommand() { func ExecCommand() {
workingDirectory, err := os.Getwd() workingDirectory, err := os.Getwd()
if err != nil { if err != nil {
@ -18,6 +20,9 @@ func ExecCommand() {
fmt.Printf("Reading command to execute...\n") fmt.Printf("Reading command to execute...\n")
linuxCommand, err := a2io.ReadString() linuxCommand, err := a2io.ReadString()
if forceLowercase {
linuxCommand = strings.ToLower(linuxCommand)
}
fmt.Printf("Command to run: %s\n", linuxCommand) fmt.Printf("Command to run: %s\n", linuxCommand)
if strings.HasPrefix(linuxCommand, "cd ") { if strings.HasPrefix(linuxCommand, "cd ") {
workingDirectory = strings.Replace(linuxCommand, "cd ", "", 1) workingDirectory = strings.Replace(linuxCommand, "cd ", "", 1)
@ -39,9 +44,13 @@ func ExecCommand() {
"Built-in commands:\r" + "Built-in commands:\r" +
"a2help - display this message\r" + "a2help - display this message\r" +
"a2wifi - set up wifi\r" + "a2wifi - set up wifi\r" +
"A2LOWER - force lowercase for II+\r" +
"\r") "\r")
return return
} }
if linuxCommand == "A2LOWER" {
forceLowercase = true
}
if linuxCommand == "a2wifi" { if linuxCommand == "a2wifi" {
a2io.WriteString("\r" + a2io.WriteString("\r" +
"Usage: a2wifi list\r" + "Usage: a2wifi list\r" +
@ -54,7 +63,7 @@ func ExecCommand() {
} }
if strings.HasPrefix(linuxCommand, "a2wifi select") { if strings.HasPrefix(linuxCommand, "a2wifi select") {
params := strings.Fields(linuxCommand) params := strings.Fields(linuxCommand)
if (len(params) != 4) { if len(params) != 4 {
a2io.WriteString("\rIncorrect number of parameters. Usage: a2wifi select SSID PASSWORD\r\r") a2io.WriteString("\rIncorrect number of parameters. Usage: a2wifi select SSID PASSWORD\r\r")
return return
} }