-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand.go
48 lines (41 loc) · 888 Bytes
/
command.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
47
48
package godm
import (
"fmt"
"io"
"log"
"github.com/halkn/godm/installer"
)
type execer interface {
exec([]string) error
}
type command struct {
outWriter io.Writer
errWriter io.Writer
config
}
func (c *command) out(v ...interface{}) {
fmt.Fprintln(c.outWriter, v...)
}
func (c *command) log(format string, v ...interface{}) {
log.Printf(format, v...)
}
func newSubCommand(sub string, cmd *command) execer {
switch sub {
case "deps":
return &depsCommand{command: cmd}
case "edit":
return &editCommand{command: cmd}
case "install":
return &installCommand{command: cmd, Installer: installer.NewCommandInstaller()}
case "update":
log.Println("update command is not yet implemented")
return nil
case "clean":
log.Println("clean command is not yet implemented")
return nil
case "version":
return &versionCommand{command: cmd}
default:
return nil
}
}