Repository navigation
Expand file tree
/
Copy pathinit_glide.go
More file actions
56 lines (49 loc) · 1.52 KB
/
Copy pathinit_glide.go
File metadata and controls
56 lines (49 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package cmd
import (
"fmt"
"github.com/Masterminds/cookoo"
"os"
)
var yamlTpl = `# Glide YAML configuration file
# Set this to your fully qualified package name, e.g.
# github.com/Masterminds/foo. This should be the
# top level package.
package: main
# Declare your project's dependencies.
import:
# Use 'go get' to fetch a package:
#- package: github.com/Masterminds/cookoo
# Get and manage a package with Git:
#- package: github.com/Masterminds/cookoo
# # The repository URL
# repo: git@github.com:Masterminds/cookoo.git
# # A tag, branch, or SHA
# ref: 1.1.0
# # the VCS type (compare to bzr, hg, svn). You should
# # set this if you know it.
# vcs: git
`
// InitGlide initializes a new Glide project.
//
// Among other things, it creates a default glide.yaml.
func InitGlide(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
fname := p.Get("filename", "glide.yaml").(string)
if gopath := os.Getenv("GOPATH"); gopath != "" {
Warn("If your GOPATH is automatically set by your shell, 'glide in' may not correctly set it.\n")
}
if _, err := os.Stat(fname); err == nil {
cwd, _ := os.Getwd()
return false, fmt.Errorf("Cowardly refusing to overwrite %s in %s", fname, cwd)
}
f, err := os.Create(fname)
if err != nil {
return false, err
}
defer f.Close()
f.WriteString(yamlTpl)
if newgopath, err := GlideGopath(); err == nil {
Info("Your new GOPATH is %s. Run 'glide gopath' to see it again.\n", newgopath)
}
Info("Initialized. You can now edit '%s'\n", fname)
return true, nil
}