Browse Source

Revert "args check could accept partly done args"

This reverts commit 79f783945e9d1cdb44f4f893c9dff23fda373ecc.
TooManySugar 3 years ago
parent
commit
5a8cf51c68
2 changed files with 19 additions and 26 deletions
  1. 1 1
      README.md
  2. 18 25
      main.go

+ 1 - 1
README.md

@@ -35,7 +35,7 @@
    - [x] UpdateData.cs - Fully ported needs testing
    - [x] UpdateData.cs - Fully ported needs testing
 
 
 
 
-## Usage
+## Usadge
 	
 	
   As for now where are no releases for GoEthemineTelegramBot, so to run it you need to compile it by yourself. It's easy you will see.
   As for now where are no releases for GoEthemineTelegramBot, so to run it you need to compile it by yourself. It's easy you will see.
   
   

+ 18 - 25
main.go

@@ -36,31 +36,24 @@ func main() {
 	}
 	}
 	myBotClient = *botClient
 	myBotClient = *botClient
 	var me = botClient.Self
 	var me = botClient.Self
-	LogInfo.Printf("Hello, World! I am user %d and my name is %s.\n",
-		me.ID, me.FirstName)
-
-	switch len(os.Args[1:]){
-		case 0:
-			fmt.Print("DataBase Username:")
-			_, err := fmt.Scanln(&appSettings.DbUser)
-			if err != nil {
-				LogError.Panic(os.Stderr, err)
-				return
-			}
-		case 1:
-			fmt.Print("DataBase Password:")
-
-			_, err = fmt.Scanln(&appSettings.DbPassword)
-			if err != nil {
-				LogError.Panic(os.Stderr, err)
-				return
-			}
-			break
-
-		default:
-			appSettings.DbUser = os.Args[1]
-			appSettings.DbPassword = os.Args[2]
-			break
+	LogInfo.Printf("Hello, World! I am user %d and my name is %s.\n", me.ID, me.FirstName)
+
+	if len(os.Args[1:]) >= 2 {
+		appSettings.DbUser = os.Args[1]
+		appSettings.DbPassword = os.Args[2]
+	} else {
+		fmt.Print("DataBase Username:")
+		_, err := fmt.Scanln(&appSettings.DbUser)
+		if err != nil {
+			LogError.Panic(os.Stderr, err)
+			return
+		}
+		fmt.Print("DataBase Password:")
+		_, err = fmt.Scanln(&appSettings.DbPassword)
+		if err != nil {
+			LogError.Panic(os.Stderr, err)
+			return
+		}
 	}
 	}
 
 
 	dBConnector.Init()
 	dBConnector.Init()