func makeWizard(do *definitions.Do) error { proceed, err := common.GetBoolResponse(ChainsMakeWelcome(), true, os.Stdin) log.WithField("=>", proceed).Debug("What the marmots heard") if err != nil { return err } if !proceed { log.Warn("The marmots will not proceed without your authorization. Exiting.") return nil } prelims := make(map[string]bool) for e, q := range ChainsMakePrelimQuestions() { prelims[e], err = common.GetBoolResponse(q, false, os.Stdin) log.WithField("=>", prelims[e]).Debug("What the marmots heard") if err != nil { return err } } accountTypes, err := LoadAccountTypes() if err != nil { return err } for _, accountT := range accountTypes { if err := assembleTypesWizard(accountT, prelims["tokens"]); err != nil { return err } } if prelims["dryrun"] { // todo check if procede or return.... } if prelims["manual"] { var err error accountTypes, err = addManualAccountType(accountTypes, 0) if err != nil { return err } } return maker(do, "mint", accountTypes) }
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 }