Exemplo n.º 1
0
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)
}
Exemplo n.º 2
0
func (f *File) setSource(args haiconf.CommandArgs) error {
	src, err := haiconf.CheckAbsolutePath("Source", args)
	if err != nil {
		return err
	}

	f.Source = src
	return nil
}
Exemplo n.º 3
0
func (f *File) setPath(args haiconf.CommandArgs) error {
	p, err := haiconf.CheckAbsolutePath("Path", args)
	if err != nil {
		return err
	}

	f.Path = p

	return nil
}
Exemplo n.º 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
}