Style changes
This commit is contained in:
parent
813de95ee7
commit
9c24c78cbc
10
command.go
10
command.go
@ -47,7 +47,7 @@ func processCmd(params []string, dir string, conf *config, flags int) error {
|
|||||||
|
|
||||||
m, ok := conf.Macros[macroName]
|
m, ok := conf.Macros[macroName]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("macro not found %s", macroName)
|
return fmt.Errorf("macro not found: %s", macroName)
|
||||||
}
|
}
|
||||||
|
|
||||||
margs := appendExpEnv(nil, m.Prefix)
|
margs := appendExpEnv(nil, m.Prefix)
|
||||||
@ -56,8 +56,8 @@ func processCmd(params []string, dir string, conf *config, flags int) error {
|
|||||||
}
|
}
|
||||||
margs = appendExpEnv(margs, m.Suffix)
|
margs = appendExpEnv(margs, m.Suffix)
|
||||||
|
|
||||||
if flags&flagVerbose == flagVerbose {
|
if flags&flagVerbose != 0 {
|
||||||
log.Printf("using macro %s", macroName)
|
log.Printf("using macro: %s", macroName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return processCmd(margs, dir, conf, flags)
|
return processCmd(margs, dir, conf, flags)
|
||||||
@ -74,8 +74,8 @@ func processCmd(params []string, dir string, conf *config, flags int) error {
|
|||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stdin = os.Stdin
|
cmd.Stdin = os.Stdin
|
||||||
|
|
||||||
if flags&flagVerbose == flagVerbose {
|
if flags&flagVerbose != 0 {
|
||||||
log.Printf("executing command %s %s", cmdName, strings.Join(cmdArgs, " "))
|
log.Printf("executing command: %s %s", cmdName, strings.Join(cmdArgs, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd.Run()
|
return cmd.Run()
|
||||||
|
@ -37,8 +37,8 @@ func processEnv(env []string, flags int) error {
|
|||||||
case len(args) == 0:
|
case len(args) == 0:
|
||||||
return fmt.Errorf("invalid environment statement")
|
return fmt.Errorf("invalid environment statement")
|
||||||
case len(args) == 1:
|
case len(args) == 1:
|
||||||
if flags&flagVerbose == flagVerbose {
|
if flags&flagVerbose != 0 {
|
||||||
log.Printf("unsetting variable %s", args[0])
|
log.Printf("unsetting variable: %s", args[0])
|
||||||
}
|
}
|
||||||
os.Unsetenv(args[0])
|
os.Unsetenv(args[0])
|
||||||
return nil
|
return nil
|
||||||
@ -48,7 +48,7 @@ func processEnv(env []string, flags int) error {
|
|||||||
value = strings.Join(args[1:], ",")
|
value = strings.Join(args[1:], ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags&flagVerbose == flagVerbose {
|
if flags&flagVerbose != 0 {
|
||||||
log.Printf("setting variable %s to %s", args[0], value)
|
log.Printf("setting variable %s to %s", args[0], value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
link.go
20
link.go
@ -32,17 +32,17 @@ import (
|
|||||||
|
|
||||||
func cleanPath(loc string, flags int) error {
|
func cleanPath(loc string, flags int) error {
|
||||||
if info, _ := os.Lstat(loc); info != nil {
|
if info, _ := os.Lstat(loc); info != nil {
|
||||||
if info.Mode()&os.ModeSymlink == os.ModeSymlink {
|
if info.Mode()&os.ModeSymlink != 0 {
|
||||||
if flags&flagVerbose == flagVerbose {
|
if flags&flagVerbose != 0 {
|
||||||
log.Printf("removing symlink %s", loc)
|
log.Printf("removing symlink: %s", loc)
|
||||||
}
|
}
|
||||||
if err := os.Remove(loc); err != nil {
|
if err := os.Remove(loc); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if flags&flagClobber == flagClobber {
|
if flags&flagClobber != 0 {
|
||||||
if flags&flagVerbose == flagVerbose {
|
if flags&flagVerbose != 0 {
|
||||||
log.Printf("clobbering path %s", loc)
|
log.Printf("clobbering path: %s", loc)
|
||||||
}
|
}
|
||||||
if err := os.RemoveAll(loc); err != nil {
|
if err := os.RemoveAll(loc); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -55,11 +55,11 @@ func cleanPath(loc string, flags int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createPath(loc string, flags int, mode os.FileMode) error {
|
func createPath(loc string, flags int, mode os.FileMode) error {
|
||||||
if flags&flagForce == flagForce {
|
if flags&flagForce != 0 {
|
||||||
parentDir, _ := path.Split(loc)
|
parentDir, _ := path.Split(loc)
|
||||||
if _, err := os.Stat(parentDir); os.IsNotExist(err) {
|
if _, err := os.Stat(parentDir); os.IsNotExist(err) {
|
||||||
if flags&flagVerbose == flagVerbose {
|
if flags&flagVerbose != 0 {
|
||||||
log.Printf("force creating path %s", parentDir)
|
log.Printf("force creating path: %s", parentDir)
|
||||||
}
|
}
|
||||||
if err := os.MkdirAll(parentDir, mode); err != nil {
|
if err := os.MkdirAll(parentDir, mode); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -126,7 +126,7 @@ func processLink(params []string, srcDir, dstDir string, flags int) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags&flagVerbose == flagVerbose {
|
if flags&flagVerbose != 0 {
|
||||||
log.Printf("linking %s to %s", srcPathAbs, dstPathAbs)
|
log.Printf("linking %s to %s", srcPathAbs, dstPathAbs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
task.go
2
task.go
@ -73,7 +73,7 @@ func processTask(taskName, srcDir, dstDir string, conf *config, flags int) error
|
|||||||
|
|
||||||
t, ok := conf.Tasks[taskName]
|
t, ok := conf.Tasks[taskName]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("task not found %s", taskName)
|
return fmt.Errorf("task not found: %s", taskName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return t.process(srcDir, dstDir, conf, flags)
|
return t.process(srcDir, dstDir, conf, flags)
|
||||||
|
Loading…
Reference in New Issue
Block a user