Style changes

This commit is contained in:
Alex Yatskov 2015-08-11 13:52:46 +09:00
parent 813de95ee7
commit 9c24c78cbc
4 changed files with 19 additions and 19 deletions

View File

@ -47,7 +47,7 @@ func processCmd(params []string, dir string, conf *config, flags int) error {
m, ok := conf.Macros[macroName]
if !ok {
return fmt.Errorf("macro not found %s", macroName)
return fmt.Errorf("macro not found: %s", macroName)
}
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)
if flags&flagVerbose == flagVerbose {
log.Printf("using macro %s", macroName)
if flags&flagVerbose != 0 {
log.Printf("using macro: %s", macroName)
}
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.Stdin = os.Stdin
if flags&flagVerbose == flagVerbose {
log.Printf("executing command %s %s", cmdName, strings.Join(cmdArgs, " "))
if flags&flagVerbose != 0 {
log.Printf("executing command: %s %s", cmdName, strings.Join(cmdArgs, " "))
}
return cmd.Run()

View File

@ -37,8 +37,8 @@ func processEnv(env []string, flags int) error {
case len(args) == 0:
return fmt.Errorf("invalid environment statement")
case len(args) == 1:
if flags&flagVerbose == flagVerbose {
log.Printf("unsetting variable %s", args[0])
if flags&flagVerbose != 0 {
log.Printf("unsetting variable: %s", args[0])
}
os.Unsetenv(args[0])
return nil
@ -48,7 +48,7 @@ func processEnv(env []string, flags int) error {
value = strings.Join(args[1:], ",")
}
if flags&flagVerbose == flagVerbose {
if flags&flagVerbose != 0 {
log.Printf("setting variable %s to %s", args[0], value)
}

20
link.go
View File

@ -32,17 +32,17 @@ import (
func cleanPath(loc string, flags int) error {
if info, _ := os.Lstat(loc); info != nil {
if info.Mode()&os.ModeSymlink == os.ModeSymlink {
if flags&flagVerbose == flagVerbose {
log.Printf("removing symlink %s", loc)
if info.Mode()&os.ModeSymlink != 0 {
if flags&flagVerbose != 0 {
log.Printf("removing symlink: %s", loc)
}
if err := os.Remove(loc); err != nil {
return err
}
} else {
if flags&flagClobber == flagClobber {
if flags&flagVerbose == flagVerbose {
log.Printf("clobbering path %s", loc)
if flags&flagClobber != 0 {
if flags&flagVerbose != 0 {
log.Printf("clobbering path: %s", loc)
}
if err := os.RemoveAll(loc); err != nil {
return err
@ -55,11 +55,11 @@ func cleanPath(loc string, flags int) error {
}
func createPath(loc string, flags int, mode os.FileMode) error {
if flags&flagForce == flagForce {
if flags&flagForce != 0 {
parentDir, _ := path.Split(loc)
if _, err := os.Stat(parentDir); os.IsNotExist(err) {
if flags&flagVerbose == flagVerbose {
log.Printf("force creating path %s", parentDir)
if flags&flagVerbose != 0 {
log.Printf("force creating path: %s", parentDir)
}
if err := os.MkdirAll(parentDir, mode); err != nil {
return err
@ -126,7 +126,7 @@ func processLink(params []string, srcDir, dstDir string, flags int) error {
return err
}
if flags&flagVerbose == flagVerbose {
if flags&flagVerbose != 0 {
log.Printf("linking %s to %s", srcPathAbs, dstPathAbs)
}

View File

@ -73,7 +73,7 @@ func processTask(taskName, srcDir, dstDir string, conf *config, flags int) error
t, ok := conf.Tasks[taskName]
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)