This commit is contained in:
asoseil 2017-11-12 11:15:57 +01:00
parent b98f93706e
commit 369215a8f1
1 changed files with 16 additions and 11 deletions

27
cmd.go
View File

@ -9,12 +9,9 @@ import (
// Tool options customizable, should be moved in Cmd // Tool options customizable, should be moved in Cmd
type tool struct { type tool struct {
dir bool dir, status bool
status bool name, err string
name string cmd, options []string
err string
cmd []string
options []string
} }
// Cmds list of go commands // Cmds list of go commands
@ -56,13 +53,21 @@ func (r *realize) clean() error {
} }
// Add a new project // Add a new project
func (r *realize) add(p *cli.Context) error { func (r *realize) add(p *cli.Context) (err error) {
path, err := filepath.Abs(p.String("path")) var path string
if err != nil { // #118 get relative and if not exist try to get abs
return err 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{ project := Project{
Name: filepath.Base(filepath.Clean(p.String("path"))), Name: filepath.Base(wdir()),
Path: path, Path: path,
Cmds: Cmds{ Cmds: Cmds{
Vet: Cmd{ Vet: Cmd{