Exemple #1
0
func (s *sharesInfo) Set(val string) error {
	switch val {
	case string(types.SharesLevelNormal), string(types.SharesLevelLow), string(types.SharesLevelHigh):
		s.Level = types.SharesLevel(val)
	default:
		n, err := strconv.Atoi(val)
		if err != nil {
			return err
		}

		s.Level = types.SharesLevelCustom
		s.Shares = int32(n)
	}

	return nil
}
Exemple #2
0
func (s *ShareFlag) Set(val string) error {
	if *s.shares == nil {
		*s.shares = &types.SharesInfo{}
	}
	switch val = strings.ToLower(val); val {
	case string(types.SharesLevelNormal), string(types.SharesLevelLow), string(types.SharesLevelHigh):
		(*s.shares).Level = types.SharesLevel(val)
		(*s.shares).Shares = 0
	default:
		n, err := strconv.Atoi(val)
		if err != nil {
			return err
		}

		(*s.shares).Level = types.SharesLevelCustom
		(*s.shares).Shares = int32(n)
	}

	return nil
}