示例#1
0
文件: brew.go 项目: jonasi/project
func dir() (string, error) {
	str, err := exec.Command("brew", "--prefix").StringOutput(true)

	if err != nil {
		return "", err
	}

	return filepath.Join(str, "Library", "Formula"), nil
}
示例#2
0
文件: brew.go 项目: jonasi/project
func Env() (map[string]string, error) {
	b, err := exec.Command("brew", "--env").Output()

	if err != nil {
		return nil, err
	}

	return parseEnv(b), nil
}
示例#3
0
文件: brew.go 项目: jonasi/project
func Config() (map[string]string, error) {
	b, err := exec.Command("brew", "config").Output()

	if err != nil {
		return nil, err
	}

	return parseConfig(b), nil
}
示例#4
0
文件: brew.go 项目: jonasi/project
func Info(name string) (*Formula, error) {
	var (
		f   []Formula
		err = exec.Command("brew", "info", "--json=v1", name).RunJSON(&f)
	)

	if err != nil {
		return nil, err
	}

	return &f[0], nil
}
示例#5
0
文件: brew.go 项目: jonasi/project
func ListInstalled() ([]*Formula, error) {
	var (
		formulae = []*Formula{}
		err      = exec.Command("brew", "info", "--installed", "--json=v1").RunJSON(&formulae)
	)

	if err != nil {
		return nil, err
	}

	return formulae, nil
}
示例#6
0
文件: brew.go 项目: jonasi/project
func LocalVersion() (*Version, error) {
	var (
		v   Version
		fmt = "Homebrew %s (git revision %s last commit"
	)

	err := exec.Command("brew", "--version").RunScanf(fmt, &v.Version, &v.Revision)

	if err != nil {
		return nil, err
	}

	// strip trailing ;
	v.Revision = v.Revision[:len(v.Revision)-1]

	return &v, nil
}
示例#7
0
文件: brew.go 项目: jonasi/project
func ListAll() ([]*Formula, error) {
	f, err := allFormulaNames()

	if err != nil {
		return nil, err
	}

	var (
		formulae = []*Formula{}
		args     = append([]string{"info", "--json=v1"}, f...)
	)

	err = exec.Command("brew", args...).RunJSON(&formulae)

	if err != nil {
		return nil, err
	}

	return formulae, nil
}
示例#8
0
文件: brew.go 项目: jonasi/project
func Upgrade(name string) (string, error) {
	return exec.Command("brew", "upgrade", name).StringOutput(true)
}
示例#9
0
文件: brew.go 项目: jonasi/project
func Remove(name string) (string, error) {
	return exec.Command("brew", "remove", name).StringOutput(true)
}
示例#10
0
文件: brew.go 项目: jonasi/project
func Install(name string) (string, error) {
	return exec.Command("brew", "install", name).StringOutput(true)
}