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.Stderr = os.Stderr
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
|
|
||||||
if flags&optVerbose == optVerbose {
|
if flags&flagVerbose == flagVerbose {
|
||||||
log.Printf("executing command %s", strings.Join(*this, " "))
|
log.Printf("executing command %s", strings.Join(*this, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
homemaker.go
12
homemaker.go
@ -37,9 +37,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
optClobber = 1 << 0
|
flagClobber = 1 << 0
|
||||||
optForce = 1 << 1
|
flagForce = 1 << 1
|
||||||
optVerbose = 1 << 2
|
flagVerbose = 1 << 2
|
||||||
)
|
)
|
||||||
|
|
||||||
func parse(filename string) (*config, error) {
|
func parse(filename string) (*config, error) {
|
||||||
@ -101,13 +101,13 @@ func main() {
|
|||||||
|
|
||||||
flags := 0
|
flags := 0
|
||||||
if *clobber {
|
if *clobber {
|
||||||
flags |= optClobber
|
flags |= flagClobber
|
||||||
}
|
}
|
||||||
if *force {
|
if *force {
|
||||||
flags |= optForce
|
flags |= flagForce
|
||||||
}
|
}
|
||||||
if *verbose {
|
if *verbose {
|
||||||
flags |= optVerbose
|
flags |= flagVerbose
|
||||||
}
|
}
|
||||||
|
|
||||||
if flag.NArg() == 2 {
|
if flag.NArg() == 2 {
|
||||||
|
12
link.go
12
link.go
@ -34,15 +34,15 @@ type link []string
|
|||||||
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 == os.ModeSymlink {
|
||||||
if flags&optVerbose == optVerbose {
|
if flags&flagVerbose == flagVerbose {
|
||||||
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&optClobber == optClobber {
|
if flags&flagClobber == flagClobber {
|
||||||
if flags&optVerbose == optVerbose {
|
if flags&flagVerbose == flagVerbose {
|
||||||
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 {
|
||||||
@ -56,10 +56,10 @@ func cleanPath(loc string, flags int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createPath(loc string, flags int) error {
|
func createPath(loc string, flags int) error {
|
||||||
if flags&optForce == optForce {
|
if flags&flagForce == flagForce {
|
||||||
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&optVerbose == optVerbose {
|
if flags&flagVerbose == flagVerbose {
|
||||||
log.Printf("force creating path %s", parentDir)
|
log.Printf("force creating path %s", parentDir)
|
||||||
}
|
}
|
||||||
if err := os.MkdirAll(parentDir, 0777); err != nil {
|
if err := os.MkdirAll(parentDir, 0777); err != nil {
|
||||||
@ -112,7 +112,7 @@ func (this *link) process(srcDir, dstDir string, flags int) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags&optVerbose == optVerbose {
|
if flags&flagVerbose == flagVerbose {
|
||||||
log.Printf("linking %s to %s", srcPath, dstPath)
|
log.Printf("linking %s to %s", srcPath, dstPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user