~psic4t/qcard

45d09ac664993f95a42076deedd5d0cc2bce10dd — psic4t 3 months ago 85dd70d
support ROLE field
7 files changed, 18 insertions(+), 4 deletions(-)

M README.md
M TODO
M defines.go
M helpers.go
M main.go
M parse.go
M qcard
M README.md => README.md +1 -0
@@ 74,6 74,7 @@ Here's a list of all attributes:
* **O:** Organisation
* **B:** Birthday
* **T:** Title
* **R:** Role
* **n:** Note

### Add new contact

M TODO => TODO +0 -1
@@ 1,5 1,4 @@
# TODO

- search by organisation
- sort by last name
- add contact from mutt

M defines.go => defines.go +1 -0
@@ 56,6 56,7 @@ type contactStruct struct {
	fullName     string
	name         string
	title        string
	role         string
	organisation string
	phoneCell    string
	phoneHome    string

M helpers.go => helpers.go +4 -2
@@ 147,11 147,13 @@ func (e contactStruct) fancyOutput() {
		if e.organisation != "" {
			fmt.Println(`  O: ` + e.organisation)
		}
		if e.role != "" {
			fmt.Println(`  R: ` + e.role)
		}
		if e.phoneCell != "" {
			//fmt.Printf(`%2s`, ` `)
			//fmt.Printf("%2s%s\n", " ", "M: "+e.phoneCell)
			//fmt.Printf("%2s%s\t%s\n", " ", "Mobile ", e.phoneCell)
			fmt.Println("  M: " + e.phoneCell)
			//fmt.Println(`M: ` + e.phoneCell)
		}
		if e.phoneHome != "" {
			fmt.Println(`  P: ` + e.phoneHome)

M main.go => main.go +5 -1
@@ 121,6 121,7 @@ func createContact(abNo int, contactData string) {
	var birthday string
	var organisation string
	var title string
	var role string

	newUUID := genUUID()



@@ 158,6 159,8 @@ func createContact(abNo int, contactData string) {
				note = "\nNOTE:" + attr[1]
			case " T":
				title = "\nTITLE:" + attr[1]
			case " R":
				role = "\nROLE:" + attr[1]
			}
		}
	}


@@ 177,7 180,8 @@ UID:` + newUUID +
		birthday +
		organisation +
		note +
		title + `
		title +
		role + `
FN:` + fullName + `
N:` + name + `
REV:` + curTime.UTC().Format(IcsFormat) + `

M parse.go => parse.go +7 -0
@@ 92,6 92,12 @@ func parseContactTitle(contactData *string) string {
	return trimField(result, "(?i)TITLE:")
}

func parseContactRole(contactData *string) string {
	re, _ := regexp.Compile(`(?i)ROLE:.*?\n`)
	result := re.FindString(*contactData)
	return trimField(result, "(?i)ROLE:")
}

func parseMain(contactData *string, contactsSlice *[]contactStruct, href, color string) {
	//fmt.Println(parseContactName(contactData))
	fullName := parseContactFullName(contactData)


@@ 103,6 109,7 @@ func parseMain(contactData *string, contactsSlice *[]contactStruct, href, color 
			fullName:     fullName,
			name:         parseContactName(contactData),
			title:        parseContactTitle(contactData),
			role:         parseContactRole(contactData),
			organisation: parseContactOrg(contactData),
			phoneCell:    parseContactPhoneCell(contactData),
			phoneHome:    parseContactPhoneHome(contactData),

M qcard => qcard +0 -0