~edwargix/tallyard

c946148d1cbd69333d34b85aa3ab0fab3b6cc0d7 — David Florness 5 years ago 34cd049
Exit tallyard if user doesn't give inputs in TUI forms
1 files changed, 10 insertions(+), 0 deletions(-)

M ui.go
M ui.go => ui.go +10 -0
@@ 2,6 2,7 @@ package main

import (
	"fmt"
	"os"
	"sort"
	"strconv"
	"unicode"


@@ 17,9 18,18 @@ func tui() (election *Election, merkleRoot []byte, electionKey string) {
		switch buttonLabel {
		case "Create Election":
			election.candidates = createElection()
			// TODO: slaves should check that len candidates >= 2
			if election.candidates == nil || len(election.candidates) == 0 {
				fmt.Printf("no candidates entered; exiting\n")
				os.Exit(0)
			}
			merkleRoot = election.createMerkle(election.candidates)
		case "Join Election":
			electionKey := joinElection()
			if electionKey == "" {
				fmt.Printf("no election key given; exiting\n")
				os.Exit(0)
			}
			merkleRoot, election.masterID = splitElectionKey(electionKey)
		}
	}