-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd_set.go
46 lines (37 loc) · 987 Bytes
/
cmd_set.go
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
package mset
import "fmt"
type set struct {
name string
description string
usage string
}
var SetCMD = set{
name: "set",
description: "Set the <name> as current, copying the settings.xml in ~.m2/",
usage: "mset set <name>",
}
func (c set) Name() string { return c.name }
func (c set) Description() string { return c.description }
func (c set) Usage() string { return c.usage }
// Run command allows to set a file stored in the catalog to be the current
// this is done copying the file from the catalog to .m2/settings.xml
func (c set) Run(args []string) error {
if len(args) < 1 {
return fmt.Errorf("insufficient arguments. USAGE: %v", c.usage)
}
name := args[0]
fpath, err := findFilePathInCatalog(name)
if err != nil {
return err
}
err = setFileToMavenPath(fpath)
if err != nil {
return err
}
err = setNameToCurrent(name)
if err != nil {
return err
}
fmt.Printf("added '%v' to current\n", name)
return nil
}