//Apply replaces all configured files on a host with the file in the current directory
Apply replaces all configured files on a host with the file in the current directory
// Apply replaces all configured files on a host with the file in the current directory
func (c *Config) Apply(hostname string) error {
	for _, d := range c.Dotfiles {
		for _, h := range d.Hosts {
			if h.Hostname == hostname && !h.Frozen {
				file, err := os.Open(d.Filepath)
				if err != nil {
					return err
				}
				defer file.Close()
				stat, err := file.Stat()
				if err != nil {
					return err
				}
				switch stat.IsDir() {
				case true:
					err = copyDir(h.Path, d.Filepath)
					if err != nil {
						return err
					}
				case false:
					err = copyFile(h.Path, d.Filepath)
					if err != nil {
						return err
					}
				}
				break
			}
		}
	}
	return nil
}
func ( c * Config ) Apply ( hostname string ) error { for _ , d := range c . Dotfiles { for _ , h := range d . Hosts { if h . Hostname == hostname && ! h . Frozen { file , err := os . Open ( d . Filepath ) if err != nil { return err } defer file . Close ( ) stat , err := file . Stat ( ) if err != nil { return err } switch stat . IsDir ( ) { case true : err = copyDir ( h . Path , d . Filepath ) if err != nil { return err } case false : err = copyFile ( h . Path , d . Filepath ) if err != nil { return err } } break } } } return nil }
Apply replaces all configured files on a host with the file in the current directory
Apply replaces all configured files on a host with the file in the current directory
// Check for which dotfiles to apply; you can cheese this by specifying a hostname in the command line