|
|
|
@ -37,16 +37,13 @@ func runAddCommand(cmd *cobra.Command, args []string) {
|
|
|
|
configSrc := args[0]
|
|
|
|
configSrc := args[0]
|
|
|
|
dirs := strings.Split(configSrc, "/")
|
|
|
|
dirs := strings.Split(configSrc, "/")
|
|
|
|
name := dirs[len(dirs) - 1] // take the last section of the path, this should be the name
|
|
|
|
name := dirs[len(dirs) - 1] // take the last section of the path, this should be the name
|
|
|
|
|
|
|
|
if name[0] == '.' {
|
|
|
|
|
|
|
|
name = name[1:]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
links := viper.GetStringMap("links")
|
|
|
|
links := viper.GetStringMap("links")
|
|
|
|
links[name] = configSrc
|
|
|
|
links[name] = configSrc
|
|
|
|
viper.Set("links", links)
|
|
|
|
viper.Set("links", links)
|
|
|
|
if !testing {
|
|
|
|
|
|
|
|
err := viper.WriteConfig()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
fmt.Printf("Problem updating dotctl config %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dotfilePath := viper.Get("dotfile-path").(string)
|
|
|
|
dotfilePath := viper.Get("dotfile-path").(string)
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,9 +66,17 @@ func runAddCommand(cmd *cobra.Command, args []string) {
|
|
|
|
if strings.ToUpper(overwrite) == "Y" {
|
|
|
|
if strings.ToUpper(overwrite) == "Y" {
|
|
|
|
addConfigToDir(fs, configSrc, dotfileDest)
|
|
|
|
addConfigToDir(fs, configSrc, dotfileDest)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("Just set up %s to link to %s\n", configSrc, dotfileDest)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
addConfigToDir(fs, configSrc, dotfileDest)
|
|
|
|
addConfigToDir(fs, configSrc, dotfileDest)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !testing {
|
|
|
|
|
|
|
|
err := viper.WriteConfig()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
fmt.Printf("Problem updating dotctl config %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func addConfigToDir(fs afero.Fs, configSrc, dotfileDest string) {
|
|
|
|
func addConfigToDir(fs afero.Fs, configSrc, dotfileDest string) {
|
|
|
|
|