示例#1
0
文件: brew.go 项目: mitallast/please
func (p *BrewProvider) Install(arg ...string) error {
	cmd := cmd.Command("brew", append([]string{"install"}, arg...)...)
	if err := cmd.Start(); err != nil {
		return err
	}
	defer cmd.Wait()
	scanner := cmd.Scanner()
	for scanner.Scan() {
		log.Printf("[brew] %s", scanner.Text())
		if err := scanner.Err(); err != nil {
			return err
		}
	}
	return nil
}
示例#2
0
文件: brew.go 项目: mitallast/please
func (p *BrewProvider) Search(arg ...string) ([]string, error) {
	cmd := cmd.Command("brew", append([]string{"search"}, arg...)...)
	if err := cmd.Start(); err != nil {
		return nil, err
	}
	defer cmd.Wait()
	matches := []string{}
	scanner := cmd.Scanner()
	for scanner.Scan() {
		line := scanner.Text()
		line = strings.Replace(line, " (installed)", "", -1)
		log.Printf("[brew] %s", line)
		matches = append(matches, line)
	}
	return matches, nil
}
示例#3
0
文件: npm.go 项目: mitallast/please
func (p *NpmProvider) getCache() (string, error) {
	cmd := cmd.Command("npm", "--no-color", "config", "get", "cache")
	if err := cmd.Start(); err != nil {
		return "", err
	}
	defer cmd.Wait()
	scanner := cmd.Scanner()
	if scanner.Scan() {
		path := strings.Trim(scanner.Text(), "\n\r")
		log.Printf("[npm] %s", path)
		return path, nil
	}
	if err := scanner.Err(); err != nil {
		return "", err
	}
	return "", os.ErrNotExist
}
示例#4
0
文件: npm.go 项目: mitallast/please
func searchNpm(arg ...string) ([]string, error) {
	cmd := cmd.Command("npm", append([]string{"--no-color", "search"}, arg...)...)
	if err := cmd.Start(); err != nil {
		return nil, err
	}
	defer cmd.Wait()
	matches := []string{}
	scanner := cmd.Scanner()
	for scanner.Scan() {
		line := scanner.Text()
		if !strings.HasPrefix(line, "NAME") {
			if index := strings.Index(line, " "); index > 0 {
				match := line[0:index]
				log.Printf("[npm] %s", match)
				matches = append(matches, match)
			}
		}
	}
	return matches, nil
}
示例#5
0
文件: yum.go 项目: mitallast/please
func (p *YumProvider) Search(arg ...string) ([]string, error) {
	cmd := cmd.Command("yum", append([]string{"search", "--quiet"}, arg...)...)
	if err := cmd.Start(); err != nil {
		return nil, err
	}
	defer cmd.Wait()
	matches := []string{}
	scanner := cmd.Scanner()
	for scanner.Scan() {
		line := scanner.Text()
		if strings.HasPrefix(line, "=") || strings.HasPrefix(line, " ") {
			continue
		}
		if index := strings.Index(line, " "); index > 0 {
			match := line[0:index]
			log.Printf("[yum] %s", match)
			matches = append(matches, match)
		}
	}
	return matches, nil
}