From 369215a8f142a5f020409912141b431f3dce48c0 Mon Sep 17 00:00:00 2001 From: asoseil Date: Sun, 12 Nov 2017 11:15:57 +0100 Subject: [PATCH] #118 fixed --- cmd.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/cmd.go b/cmd.go index 69e7933..3fd1f4b 100644 --- a/cmd.go +++ b/cmd.go @@ -9,12 +9,9 @@ import ( // Tool options customizable, should be moved in Cmd type tool struct { - dir bool - status bool - name string - err string - cmd []string - options []string + dir, status bool + name, err string + cmd, options []string } // Cmds list of go commands @@ -56,13 +53,21 @@ func (r *realize) clean() error { } // Add a new project -func (r *realize) add(p *cli.Context) error { - path, err := filepath.Abs(p.String("path")) - if err != nil { - return err +func (r *realize) add(p *cli.Context) (err error) { + var path string + // #118 get relative and if not exist try to get abs + if _, err = os.Stat(p.String("path")); os.IsNotExist(err) { + // path doesn't exist + path, err = filepath.Abs(p.String("path")) + if err != nil { + return err + } + }else{ + path = filepath.Clean(p.String("path")) } + project := Project{ - Name: filepath.Base(filepath.Clean(p.String("path"))), + Name: filepath.Base(wdir()), Path: path, Cmds: Cmds{ Vet: Cmd{