//Update searches for each file in a config, and if it matches hostname
//replaces the file in the current directory with the file on that host
Update searches for each file in a config, and if it matches hostname
replaces the file in the current directory with the file on that host
// Update searches for each file in a config and if it matches hostname // replaces the file in the current directory with the file on that host
func (c *Config) Update(hostname string) error {
	for _, d := range c.Dotfiles {
		for _, h := range d.Hosts {
			if h.Hostname == hostname && !h.Frozen {
				file, err := os.Open(h.Path)
				if err != nil {
					return err
				}
				defer file.Close()
				stat, err := file.Stat()
				if err != nil {
					return err
				}
				switch stat.IsDir() {
				case true:
					err = copyDir(d.Filepath, h.Path)
					if err != nil {
						return err
					}
				case false:
					err = copyFile(d.Filepath, h.Path)
					if err != nil {
						return err
					}
				}
				break
			}
		}
	}
	return nil
}
func ( c * Config ) Update ( hostname string ) error { for _ , d := range c . Dotfiles { for _ , h := range d . Hosts { if h . Hostname == hostname && ! h . Frozen { file , err := os . Open ( h . Path ) if err != nil { return err } defer file . Close ( ) stat , err := file . Stat ( ) if err != nil { return err } switch stat . IsDir ( ) { case true : err = copyDir ( d . Filepath , h . Path ) if err != nil { return err } case false : err = copyFile ( d . Filepath , h . Path ) if err != nil { return err } } break } } } return nil }
Update searches for each file in a config, and if it matches hostname
replaces the file in the current directory with the file on that host
Update searches for each file in a config and if it matches hostname replaces the file in the current directory with the file on that host