~psic4t/qcard

85dd70da644380a0a96770d6379b4e4e480d2279 — psic4t 3 months ago b9cf16c
enable sorting by last name in configuration
5 files changed, 13 insertions(+), 4 deletions(-)

M config-sample.json
M defines.go
M helpers.go
M main.go
M qcard
M config-sample.json => config-sample.json +2 -1
@@ 6,5 6,6 @@
			"Password":"supersecret"
		}
	],
        "DetailThreshold": 3
        "DetailThreshold": 3,
	"SortByLastname": false
}

M defines.go => defines.go +1 -0
@@ 47,6 47,7 @@ type configStruct struct {
		Password string
	}
	DetailThreshold int
	SortByLastname  bool
}

type contactStruct struct {

M helpers.go => helpers.go +5 -1
@@ 133,7 133,11 @@ func (e contactStruct) fancyOutput() {
		if showColor {
			fmt.Print(e.Color + colorBlock + ColDefault + ` `)
		}
		fmt.Println(e.fullName)
		if config.SortByLastname {
			fmt.Println(e.name)
		} else {
			fmt.Println(e.fullName)
		}
	}

	if showDetails {

M main.go => main.go +5 -2
@@ 80,8 80,11 @@ func showAddresses(abNo int) {

	// TODO: Allow sort by first and last name
	sort.Slice(contactsSlice, func(i, j int) bool {
		return contactsSlice[i].fullName < contactsSlice[j].fullName
		//return contactsSlice[i].name < contactsSlice[j].name
		if config.SortByLastname {
			return contactsSlice[i].name < contactsSlice[j].name
		} else {
			return contactsSlice[i].fullName < contactsSlice[j].fullName
		}
	})

	if len(contactsSlice) == 0 {

M qcard => qcard +0 -0