Style fixes
This commit is contained in:
parent
420f655453
commit
eaa73b87c6
@ -32,18 +32,18 @@ import (
|
|||||||
|
|
||||||
type command []string
|
type command []string
|
||||||
|
|
||||||
func (this *command) process(dir string, flags int) error {
|
func (c *command) process(dir string, flags int) error {
|
||||||
if len(*this) < 1 {
|
if len(*c) < 1 {
|
||||||
return fmt.Errorf("command element is invalid")
|
return fmt.Errorf("command element is invalid")
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command((*this)[0], (*this)[1:]...)
|
cmd := exec.Command((*c)[0], (*c)[1:]...)
|
||||||
cmd.Dir = dir
|
cmd.Dir = dir
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
|
|
||||||
if flags&flagVerbose == flagVerbose {
|
if flags&flagVerbose == flagVerbose {
|
||||||
log.Printf("executing command %s", strings.Join(*this, " "))
|
log.Printf("executing command %s", strings.Join(*c, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd.Run()
|
return cmd.Run()
|
||||||
|
@ -29,13 +29,13 @@ type config struct {
|
|||||||
tasksHandled map[string]bool
|
tasksHandled map[string]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *config) process(srcDir, dstDir, taskName string, flags int) error {
|
func (c *config) process(srcDir, dstDir, taskName string, flags int) error {
|
||||||
this.tasksHandled = make(map[string]bool)
|
c.tasksHandled = make(map[string]bool)
|
||||||
|
|
||||||
task, ok := this.Tasks[taskName]
|
task, ok := c.Tasks[taskName]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("task not found %s", taskName)
|
return fmt.Errorf("task not found %s", taskName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return task.process(taskName, srcDir, dstDir, this, flags)
|
return task.process(taskName, srcDir, dstDir, c, flags)
|
||||||
}
|
}
|
||||||
|
14
link.go
14
link.go
@ -72,21 +72,21 @@ func createPath(loc string, flags int, mode os.FileMode) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *link) parse() (string, string, os.FileMode, error) {
|
func (l *link) parse() (string, string, os.FileMode, error) {
|
||||||
length := len(*this)
|
length := len(*l)
|
||||||
if length < 1 || length > 3 {
|
if length < 1 || length > 3 {
|
||||||
return "", "", 0, fmt.Errorf("link element is invalid")
|
return "", "", 0, fmt.Errorf("link element is invalid")
|
||||||
}
|
}
|
||||||
|
|
||||||
dstPath := (*this)[0]
|
dstPath := (*l)[0]
|
||||||
srcPath := dstPath
|
srcPath := dstPath
|
||||||
if length > 1 {
|
if length > 1 {
|
||||||
srcPath = (*this)[1]
|
srcPath = (*l)[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
var mode os.FileMode = 0755
|
var mode os.FileMode = 0755
|
||||||
if length > 2 {
|
if length > 2 {
|
||||||
parsed, err := strconv.ParseUint((*this)[2], 0, 64)
|
parsed, err := strconv.ParseUint((*l)[2], 0, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", 0, err
|
return "", "", 0, err
|
||||||
}
|
}
|
||||||
@ -97,8 +97,8 @@ func (this *link) parse() (string, string, os.FileMode, error) {
|
|||||||
return srcPath, dstPath, mode, nil
|
return srcPath, dstPath, mode, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *link) process(srcDir, dstDir string, flags int) error {
|
func (l *link) process(srcDir, dstDir string, flags int) error {
|
||||||
srcPath, dstPath, mode, err := this.parse()
|
srcPath, dstPath, mode, err := l.parse()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
8
task.go
8
task.go
@ -30,7 +30,7 @@ type task struct {
|
|||||||
Cmds []command
|
Cmds []command
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *task) process(taskName, srcDir, dstDir string, conf *config, flags int) error {
|
func (t *task) process(taskName, srcDir, dstDir string, conf *config, flags int) error {
|
||||||
handled, ok := conf.tasksHandled[taskName]
|
handled, ok := conf.tasksHandled[taskName]
|
||||||
if ok && handled {
|
if ok && handled {
|
||||||
return nil
|
return nil
|
||||||
@ -38,7 +38,7 @@ func (this *task) process(taskName, srcDir, dstDir string, conf *config, flags i
|
|||||||
|
|
||||||
conf.tasksHandled[taskName] = true
|
conf.tasksHandled[taskName] = true
|
||||||
|
|
||||||
for _, depName := range this.Deps {
|
for _, depName := range t.Deps {
|
||||||
depTask, ok := conf.Tasks[depName]
|
depTask, ok := conf.Tasks[depName]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("task dependency not found %s", depName)
|
return fmt.Errorf("task dependency not found %s", depName)
|
||||||
@ -50,7 +50,7 @@ func (this *task) process(taskName, srcDir, dstDir string, conf *config, flags i
|
|||||||
}
|
}
|
||||||
|
|
||||||
if flags&flagNoLink == 0 {
|
if flags&flagNoLink == 0 {
|
||||||
for _, currLink := range this.Links {
|
for _, currLink := range t.Links {
|
||||||
if err := currLink.process(srcDir, dstDir, flags); err != nil {
|
if err := currLink.process(srcDir, dstDir, flags); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ func (this *task) process(taskName, srcDir, dstDir string, conf *config, flags i
|
|||||||
}
|
}
|
||||||
|
|
||||||
if flags&flagNoCmd == 0 {
|
if flags&flagNoCmd == 0 {
|
||||||
for _, currCmd := range this.Cmds {
|
for _, currCmd := range t.Cmds {
|
||||||
if err := currCmd.process(dstDir, flags); err != nil {
|
if err := currCmd.process(dstDir, flags); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user