From 39472171cab7415e558427a42097bcb3945c8041 Mon Sep 17 00:00:00 2001 From: Injamul Mohammad Mollah Date: Mon, 28 Sep 2020 17:56:46 +0530 Subject: [PATCH] fix bugs --- cmd/generate.go | 10 +++++++--- cmd/remove.go | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/generate.go b/cmd/generate.go index 0e58095..a535a05 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -46,6 +46,12 @@ func generateRun(cmd *cobra.Command, args []string) { err error ) + if len(args) > 1 { + color.Red("Error: too much arguments") + color.Yellow("Usage: gpassmanager generate [password length]") + os.Exit(0) + } + if len(args) != 0 { passLength, err = strconv.Atoi(args[0]) if err != nil { @@ -78,10 +84,8 @@ func generateRun(cmd *cobra.Command, args []string) { // } // } - fmt.Println(passLength) - pass := gpm.GeneratePassword(passLength) - fmt.Println("Password: " + pass + "\n") + fmt.Println("Password: " + pass + "") if _, err := os.Stat(gpm.DatabaseFile); os.IsNotExist(err) { gpm.CreateDatabase() diff --git a/cmd/remove.go b/cmd/remove.go index 468b842..8535850 100644 --- a/cmd/remove.go +++ b/cmd/remove.go @@ -42,12 +42,12 @@ var removeCmd = &cobra.Command{ func removeRun(cmd *cobra.Command, args []string) { if len(args) == 0 { color.Red("Error: too short argument") - color.Yellow("Usaage: gpassmanager remove [id]") + color.Yellow("Usage: gpassmanager remove [id]") os.Exit(0) } if len(args) > 1 { color.Red("Error: too much arguments") - color.Yellow("Usaage: gpassmanager remove [id]") + color.Yellow("Usage: gpassmanager remove [id]") os.Exit(0) } i, err := strconv.Atoi(args[0])