Exemplo n.º 1
0
func (h *HttpGet) setTo(args haiconf.CommandArgs) error {
	t, _ := haiconf.CheckString("To", args)

	if len(t) == 0 {
		return haiconf.NewArgError("To must be provided", args)
	}

	if !utils.HasFileName(t) {
		return haiconf.NewArgError(t+" must be a file name", args)
	}

	dir := filepath.Dir(t)
	id, err := utils.IsDir(dir)
	if err != nil {
		return haiconf.NewArgError(err.Error(), args)
	}

	if !id {
		return haiconf.NewArgError(dir+" is not a directory", args)
	}

	h.To = t

	return nil
}
Exemplo n.º 2
0
func (t *UnTarGz) setDest(args haiconf.CommandArgs) error {
	d, _ := haiconf.CheckString("Dest", args)
	if len(d) == 0 {
		return haiconf.NewArgError("Dest must be provided", args)
	}

	id, err := utils.IsDir(d)
	if err != nil {
		return err
	}

	if !id {
		return haiconf.NewArgError(d+" is not a directory", args)
	}

	t.Dest = d
	return nil
}
Exemplo n.º 3
0
func (t *TarGz) setDest(args haiconf.CommandArgs) error {
	d, _ := haiconf.CheckString("Dest", args)
	if len(d) == 0 {
		return haiconf.NewArgError("Dest must be provided", args)
	}

	if !strings.HasSuffix(d, ".tar.gz") {
		return haiconf.NewArgError("No tarball name provided", args)
	}

	id, err := utils.IsDir(filepath.Dir(d))
	if err != nil {
		return err
	}

	if !id {
		return haiconf.NewArgError(d+" is not a directory", args)
	}

	t.Dest = d
	return nil
}