diff --git a/command.go b/command.go index 240293c..960296f 100644 --- a/command.go +++ b/command.go @@ -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, " ")) } diff --git a/environment.go b/environment.go index 8ccd0cb..6c94589 100644 --- a/environment.go +++ b/environment.go @@ -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) } diff --git a/homemaker.go b/homemaker.go index 4b77040..4a6fc4b 100644 --- a/homemaker.go +++ b/homemaker.go @@ -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 { diff --git a/link.go b/link.go index 6cd4bc3..81cd5e0 100644 --- a/link.go +++ b/link.go @@ -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) } diff --git a/task.go b/task.go index a018dc2..0d13522 100644 --- a/task.go +++ b/task.go @@ -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