Пример #1
0
func assembleTypesWizard(accountT *definitions.AccountType, tokenIze bool) error {
	var err error
	accountT.Number, err = common.GetIntResponse(AccountTypeIntro(accountT), accountT.Number, reader)
	log.WithField("=>", accountT.Number).Debug("What the marmots heard")
	if err != nil {
		return err
	}

	if tokenIze && accountT.Number > 0 {
		accountT.Tokens, err = common.GetIntResponse(AccountTypeTokens(accountT), accountT.Tokens, reader)
		log.WithField("=>", accountT.Tokens).Debug("What the marmots heard")
		if err != nil {
			return err
		}
	}

	if accountT.Perms["bond"] == 1 && accountT.Number > 0 {
		accountT.ToBond, err = common.GetIntResponse(AccountTypeToBond(accountT), accountT.ToBond, reader)
		log.WithField("=>", accountT.ToBond).Debug("What the marmots heard")
		if err != nil {
			return err
		}
	} else {
		log.Info("Setting accountType.ToBond to 0")
		log.WithField("=>", accountT.Name).Debug("No bond permissions")
		accountT.ToBond = 0
	}

	return nil
}
Пример #2
0
func addManualAccountType(accountT []*definitions.AccountType, iterator int) ([]*definitions.AccountType, error) {
	var err error
	thisActT := &definitions.AccountType{}
	thisActT.Name = fmt.Sprintf("%s_%02d", "manual", iterator)
	iterator++

	thisActT.Number, err = common.GetIntResponse(AccountTypeManualIntro(), 1, reader)
	if err != nil {
		return nil, err
	}

	thisActT.Tokens, err = common.GetIntResponse(AccountTypeManualTokens(), 0, reader)
	if err != nil {
		return nil, err
	}

	thisActT.ToBond, err = common.GetIntResponse(AccountTypeManualToBond(), 0, reader)
	if err != nil {
		return nil, err
	}

	thisActT.Perms = make(map[string]int)
	for _, perm := range AccountTypeManualPerms() {
		thisActT.Perms[perm], err = common.GetIntResponse(AccountTypeManualPermsQuestion(perm), 0, reader)
	}

	name, err := common.GetStringResponse(AccountTypeManualSave(), "", reader)
	if name != "" {
		thisActT.Name = name
		if err := util.SaveAccountType(thisActT); err != nil {
			return nil, err
		}
	}
	accountT = append(accountT, thisActT)

	again, err := common.GetBoolResponse(AccountTypeManualAnother(), false, reader)
	if err != nil {
		return nil, err
	}
	if again {
		return addManualAccountType(accountT, iterator)
	}
	return accountT, nil
}