Revert "Style changes"

This reverts commit a644ed8f7f.
This commit is contained in:
Alex Yatskov 2015-08-10 18:33:22 +09:00
parent db4c127550
commit 813de95ee7
5 changed files with 23 additions and 23 deletions

View File

@ -56,7 +56,7 @@ func processCmd(params []string, dir string, conf *config, flags int) error {
}
margs = appendExpEnv(margs, m.Suffix)
if flags&FLAG_VERBOSE == FLAG_VERBOSE {
if flags&flagVerbose == flagVerbose {
log.Printf("using macro %s", macroName)
}
@ -74,7 +74,7 @@ func processCmd(params []string, dir string, conf *config, flags int) error {
cmd.Stdout = os.Stdout
cmd.Stdin = os.Stdin
if flags&FLAG_VERBOSE == FLAG_VERBOSE {
if flags&flagVerbose == flagVerbose {
log.Printf("executing command %s %s", cmdName, strings.Join(cmdArgs, " "))
}

View File

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

View File

@ -37,12 +37,12 @@ import (
)
const (
FLAG_CLOBBER = 1 << iota
FLAG_FORCE
FLAG_VERBOSE
FLAG_NO_CMD
FLAG_NO_LINK
FLAG_NO_MACRO
flagClobber = 1 << iota
flagForce
flagVerbose
flagNoCmd
flagNoLink
flagNoMacro
)
func parseCfg(filename string) (*config, error) {
@ -98,19 +98,19 @@ func main() {
flags := 0
if *clobber {
flags |= FLAG_CLOBBER
flags |= flagClobber
}
if *force {
flags |= FLAG_FORCE
flags |= flagForce
}
if *verbose {
flags |= FLAG_VERBOSE
flags |= flagVerbose
}
if *nocmd {
flags |= FLAG_NO_CMD
flags |= flagNoCmd
}
if *nolink {
flags |= FLAG_NO_LINK
flags |= flagNoLink
}
if flag.NArg() == 2 {

12
link.go
View File

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

View File

@ -44,7 +44,7 @@ func (t *task) process(srcDir, dstDir string, conf *config, flags int) error {
}
}
if flags&FLAG_NO_CMD == 0 {
if flags&flagNoCmd == 0 {
for _, currCmd := range t.Cmds {
if err := processCmd(currCmd, dstDir, conf, flags); err != nil {
return err
@ -52,7 +52,7 @@ func (t *task) process(srcDir, dstDir string, conf *config, flags int) error {
}
}
if flags&FLAG_NO_LINK == 0 {
if flags&flagNoLink == 0 {
for _, currLink := range t.Links {
if err := processLink(currLink, srcDir, dstDir, flags); err != nil {
return err