From 747b4e84854ee52125a789cff1417551b6d07af6 Mon Sep 17 00:00:00 2001 From: Muhammad Hewedy Date: Wed, 6 May 2020 02:48:17 +0300 Subject: [PATCH] enahnce output in case of cmd create error --- cmd/create.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/create.go b/cmd/create.go index 9ef1258..a8c96a6 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -38,13 +38,14 @@ $ vermin create To create VM with default settings and provide a script to provision the VM: $ vermin create `, - RunE: func(cmd *cobra.Command, args []string) error { + Run: func(cmd *cobra.Command, args []string) { imageName := args[0] var script string if len(args) > 1 { script = args[1] if _, err := os.Stat(script); err != nil { - return err + fmt.Println("file not found", script) + os.Exit(1) } } cpus, _ := cmd.Flags().GetInt("cpus") @@ -52,10 +53,11 @@ $ vermin create vmName, err := vms.Create(imageName, script, cpus, mem) if err != nil { - return err + fmt.Println(err) + os.Exit(1) } + fmt.Printf("VM created successfuly\n\nTo start using the VM use:\n$ vermin ssh %s\n", vmName) - return nil }, Args: func(cmd *cobra.Command, args []string) error { if len(args) < 1 {