示例#1
0
文件: storage.go 项目: ryo33/zenv
func WriteStorage(name, key, subkey string, data []string) {
	if len(name) == 0 {
		name = STORAGE
	}
	util.PrepareDir(GetStorageDir(name, key))
	util.WriteFile(getStorageFilePath(name, key, subkey), data)
}
示例#2
0
文件: global.go 项目: ryo33/zenv
func removeEnvDir(name string) {
	dirs := getEnvDirs()
	for i, dir := range dirs {
		if name == dir {
			util.WriteFile(path.Join(util.GetHomeDir(), zenv.ZENV, DIRS), append(dirs[:i], dirs[i+1:]...))
			return
		}
	}
}
示例#3
0
文件: global.go 项目: ryo33/zenv
func RemoveGlobalEnv(name string) {
	envFile := GetEnvsPath()
	tmp := util.ReadFile(envFile)
	result := []string{}
	for _, en := range tmp {
		if en != name {
			result = append(result, en)
		}
	}
	util.WriteFile(envFile, result)
}
示例#4
0
文件: global.go 项目: ryo33/zenv
func (env *Env) AddGlobalEnv(force bool) {
	envFile := GetEnvsPath()
	tmp := util.ReadFile(envFile)
	for _, en := range tmp {
		if en == env.name {
			if !force {
				util.PrintErrorMessage("already exists\n--force to overwrite") //TODO already exists  --force to overwrite
			}
			break
		}
	}
	util.WriteFile(envFile, append(tmp, env.name))
}
示例#5
0
文件: io.go 项目: ryo33/zenv
//write info
func (env *Env) writeInfo() {
	info := append([]string{}, "name"+SEPARATOR+env.name, "dir"+SEPARATOR+env.dir)
	if env.global {
		info = append(info, "global"+SEPARATOR+"true")
	} else {
		info = append(info, "global"+SEPARATOR+"false")
	}
	if env.recursive {
		info = append(info, "recursive"+SEPARATOR+"true")
	} else {
		info = append(info, "recursive"+SEPARATOR+"false")
	}
	if env.exclusive {
		info = append(info, "exclusive"+SEPARATOR+"true")
	} else {
		info = append(info, "exclusive"+SEPARATOR+"false")
	}
	util.WriteFile(path.Join(env.dir, INFO), info)
}
示例#6
0
文件: settings.go 项目: ryo33/zenv
func (items Items) Write(dir string) {
	// each lables
	for key, its := range items.ToMap() {
		result := []string{}
		se, ok := settings[key]
		if !ok {
			util.PrintErrorMessageContinue(key + " lable is undefined")
		}
		for _, it := range its {
			if str := se.write(it); len(str) > 0 {
				result = append(result, str)
			} else {
				util.Print("黄金") // This should not be called.
			}
		}
		if len(result) > 0 {
			util.WriteFile(path.Join(dir, key), result)
		}
	}
}
示例#7
0
文件: temporal.go 项目: ryo33/zenv
func updateLast(key string) {
	if util.Exists(GetStorageDir(TMP, key)) {
		util.WriteFile(getStorageFilePath(TMP, key, LAST), []string{Now()})
	}
}
示例#8
0
文件: global.go 项目: ryo33/zenv
func (env *Env) addEnvDir() {
	dirs := getEnvDirs()
	if !util.Contains(dirs, env.name) {
		util.WriteFile(path.Join(util.GetHomeDir(), zenv.ZENV, DIRS), append(dirs, env.name))
	}
}