Renaming flags
This commit is contained in:
parent
3ccf4ff804
commit
74fc847f6c
@ -46,7 +46,7 @@ func (this *command) process(dir string, flags int) error {
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = os.Stdout
|
||||
|
||||
if flags&optVerbose == optVerbose {
|
||||
if flags&flagVerbose == flagVerbose {
|
||||
log.Printf("executing command %s", strings.Join(*this, " "))
|
||||
}
|
||||
|
||||
|
12
homemaker.go
12
homemaker.go
@ -37,9 +37,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
optClobber = 1 << 0
|
||||
optForce = 1 << 1
|
||||
optVerbose = 1 << 2
|
||||
flagClobber = 1 << 0
|
||||
flagForce = 1 << 1
|
||||
flagVerbose = 1 << 2
|
||||
)
|
||||
|
||||
func parse(filename string) (*config, error) {
|
||||
@ -101,13 +101,13 @@ func main() {
|
||||
|
||||
flags := 0
|
||||
if *clobber {
|
||||
flags |= optClobber
|
||||
flags |= flagClobber
|
||||
}
|
||||
if *force {
|
||||
flags |= optForce
|
||||
flags |= flagForce
|
||||
}
|
||||
if *verbose {
|
||||
flags |= optVerbose
|
||||
flags |= flagVerbose
|
||||
}
|
||||
|
||||
if flag.NArg() == 2 {
|
||||
|
12
link.go
12
link.go
@ -34,15 +34,15 @@ type link []string
|
||||
func cleanPath(loc string, flags int) error {
|
||||
if info, _ := os.Lstat(loc); info != nil {
|
||||
if info.Mode()&os.ModeSymlink == os.ModeSymlink {
|
||||
if flags&optVerbose == optVerbose {
|
||||
if flags&flagVerbose == flagVerbose {
|
||||
log.Printf("removing symlink %s", loc)
|
||||
}
|
||||
if err := os.Remove(loc); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if flags&optClobber == optClobber {
|
||||
if flags&optVerbose == optVerbose {
|
||||
if flags&flagClobber == flagClobber {
|
||||
if flags&flagVerbose == flagVerbose {
|
||||
log.Printf("clobbering path %s", loc)
|
||||
}
|
||||
if err := os.RemoveAll(loc); err != nil {
|
||||
@ -56,10 +56,10 @@ func cleanPath(loc string, flags int) error {
|
||||
}
|
||||
|
||||
func createPath(loc string, flags int) error {
|
||||
if flags&optForce == optForce {
|
||||
if flags&flagForce == flagForce {
|
||||
parentDir, _ := path.Split(loc)
|
||||
if _, err := os.Stat(parentDir); os.IsNotExist(err) {
|
||||
if flags&optVerbose == optVerbose {
|
||||
if flags&flagVerbose == flagVerbose {
|
||||
log.Printf("force creating path %s", parentDir)
|
||||
}
|
||||
if err := os.MkdirAll(parentDir, 0777); err != nil {
|
||||
@ -112,7 +112,7 @@ func (this *link) process(srcDir, dstDir string, flags int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if flags&optVerbose == optVerbose {
|
||||
if flags&flagVerbose == flagVerbose {
|
||||
log.Printf("linking %s to %s", srcPath, dstPath)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user