Add nocmd and nolink command line arguments
This commit is contained in:
parent
0550d9c77f
commit
5e41714234
@ -232,6 +232,14 @@ provides a more detailed description of what the parameters do.
|
||||
for the current user, and as long as you are just using this application to manage dot-files, will probably never
|
||||
need to be changed.
|
||||
|
||||
* `nocmd`
|
||||
|
||||
Do not execute commands for the `cmd` blocks inside of tasks.
|
||||
|
||||
* `nolink`
|
||||
|
||||
Do not create links for the `link` blocks inside of tasks.
|
||||
|
||||
* `force`
|
||||
|
||||
Sometimes dot-files for an application are nested within parent directories that must exist in order to allow the
|
||||
|
10
homemaker.go
10
homemaker.go
@ -40,6 +40,8 @@ const (
|
||||
flagClobber = 1 << iota
|
||||
flagForce
|
||||
flagVerbose
|
||||
flagNoCmd
|
||||
flagNoLink
|
||||
)
|
||||
|
||||
func parse(filename string) (*config, error) {
|
||||
@ -96,6 +98,8 @@ func main() {
|
||||
force := flag.Bool("force", true, "create parent directories to target")
|
||||
clobber := flag.Bool("clobber", false, "delete files and directories at target")
|
||||
verbose := flag.Bool("verbose", false, "verbose output")
|
||||
nocmd := flag.Bool("nocmd", false, "don't execute commands")
|
||||
nolink := flag.Bool("nolink", false, "don't create links")
|
||||
|
||||
flag.Usage = usage
|
||||
flag.Parse()
|
||||
@ -110,6 +114,12 @@ func main() {
|
||||
if *verbose {
|
||||
flags |= flagVerbose
|
||||
}
|
||||
if *nocmd {
|
||||
flags |= flagNoCmd
|
||||
}
|
||||
if *nolink {
|
||||
flags |= flagNoLink
|
||||
}
|
||||
|
||||
if flag.NArg() == 2 {
|
||||
conf, err := parse(flag.Arg(0))
|
||||
|
4
task.go
4
task.go
@ -49,17 +49,21 @@ func (this *task) process(taskName, srcDir, dstDir string, conf *config, flags i
|
||||
}
|
||||
}
|
||||
|
||||
if flags&flagNoLink == 0 {
|
||||
for _, currLink := range this.Links {
|
||||
if err := currLink.process(srcDir, dstDir, flags); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if flags&flagNoCmd == 0 {
|
||||
for _, currCmd := range this.Cmds {
|
||||
if err := currCmd.process(dstDir, flags); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user