예제 #1
0
파일: main.go 프로젝트: wreese/valuestore
func pretendElapsedCmd(r ring.Ring, b *ring.Builder, args []string) error {
	if b == nil {
		return fmt.Errorf("only valid for builder files")
	}
	if len(args) != 1 {
		return fmt.Errorf("syntax: <minutes>")
	}
	m, err := strconv.Atoi(args[0])
	if err != nil {
		return fmt.Errorf("could not parse %#v: %s", args[0], err.Error())
	}
	if m < 0 {
		return fmt.Errorf("cannot pretend to go backwards in time")
	}
	if m > math.MaxUint16 {
		return fmt.Errorf("cannot pretend to elapse more than %d minutes", math.MaxUint16)
	}
	b.PretendElapsed(uint16(m))
	return nil
}