Exemplo n.º 1
0
func within(d time.Duration, f func() bool) int {
	start := time.Now()
	end := start.Add(d)
	p := cli.BeginProgress("Polling")
	for {
		if f() {
			p.Done("Success!")
			return 0
		}
		if time.Now().After(end) {
			break
		}
		p.Increment()
		time.Sleep(time.Second)
	}
	p.Done("Timeout")
	return 1
}
Exemplo n.º 2
0
func Update() error {
	c = nil
	p := cli.BeginProgress("Updating config")
	Set("last-update-check", time.Now().Format(time.RFC3339))
	props := Properties()
	serverURL := props["sous-server"]
	if serverURL == "" {
		p.Done("Failed")
		return fmt.Errorf("sous-server not set; use `sous config sous-server http://your.sous.server`")
	}
	var c *Config
	if err := getJSON(&c, "%s/config", serverURL); err != nil {
		p.Done("Failed")
		return err
	}
	file.WriteJSON(c, "~/.sous/config")
	p.Done("Done")
	return nil
}