示例#1
0
文件: aptget.go 项目: jeromer/haiconf
func (ag *AptGet) setPackages(args haiconf.CommandArgs) error {
	pl, _ := haiconf.CheckStringList("Packages", args)

	if len(pl) > 0 {
		ag.Packages = stringutils.RemoveDuplicates(pl)
		return nil
	}

	pfs, _ := haiconf.CheckAbsolutePath("PackagesFromSource", args)
	if pfs != "" {
		buff, err := ioutil.ReadFile(pfs)
		if err != nil {
			return err
		}

		nlSplit := func(r rune) bool {
			if r == '\n' {
				return true
			}
			return false
		}

		pkgs := strings.FieldsFunc(string(buff), nlSplit)
		ag.Packages = stringutils.RemoveDuplicates(pkgs)

		return nil
	}

	msg := "You must provide a value for either Packages or PackagesFromSource"
	return haiconf.NewArgError(msg, args)
}
示例#2
0
文件: file.go 项目: jeromer/haiconf
func (f *File) setSource(args haiconf.CommandArgs) error {
	src, err := haiconf.CheckAbsolutePath("Source", args)
	if err != nil {
		return err
	}

	f.Source = src
	return nil
}
示例#3
0
文件: file.go 项目: jeromer/haiconf
func (f *File) setPath(args haiconf.CommandArgs) error {
	p, err := haiconf.CheckAbsolutePath("Path", args)
	if err != nil {
		return err
	}

	f.Path = p

	return nil
}
示例#4
0
func (d *Directory) setPath(args haiconf.CommandArgs) error {
	p, err := haiconf.CheckAbsolutePath("Path", args)
	if err != nil {
		return err
	}

	d.Path = p

	return nil
}