From 3edc70a7dfeb0269813c639c7aae92b6a3083827 Mon Sep 17 00:00:00 2001 From: Dan O'Neill Date: Fri, 8 Dec 2023 19:12:10 -0800 Subject: [PATCH] add all flag --- cmd/user.go | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/cmd/user.go b/cmd/user.go index 6b51dd6..644f4b1 100644 --- a/cmd/user.go +++ b/cmd/user.go @@ -34,23 +34,42 @@ func user() { } if userResponse != nil { - data := []string{ - userResponse.Data.Username, - userResponse.Data.Email, - userResponse.Data.FirstName, - userResponse.Data.LastName, - userResponse.Data.ID, - userResponse.Data.Pin, - userResponse.Data.Subject.ID, - } + switch { + case all: + allUserDataFmt := fmt.Sprintf("username: %s\nemail: %s\nfirst name: %s\nlast name: %s\nrole: %s\nis staff: %t\nis superuser: %t\ndate joined: %s\nid: %s\nisactive: %t\nlast login: %s\npin: %s\nsubject id: %s", + userResponse.Data.Username, + userResponse.Data.Email, + userResponse.Data.FirstName, + userResponse.Data.LastName, + userResponse.Data.Role, + userResponse.Data.IsStaff, + userResponse.Data.IsSuperUser, + userResponse.Data.DateJoined, + userResponse.Data.ID, + userResponse.Data.IsActive, + userResponse.Data.LastLogin, + userResponse.Data.Pin, + userResponse.Data.Subject.ID) + fmt.Println(allUserDataFmt) + default: + userData := []string{ + userResponse.Data.Username, + userResponse.Data.Email, + userResponse.Data.FirstName, + userResponse.Data.LastName, + userResponse.Data.ID, + userResponse.Data.Pin, + userResponse.Data.Subject.ID, + } - table := tablewriter.NewWriter(os.Stdout) - table.SetHeader([]string{"Username", "Email", "First Name", "Last Name", "ID", "Pin", "Subject ID"}) - table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false}) - table.SetCenterSeparator("|") - table.Append(data) + table := tablewriter.NewWriter(os.Stdout) + table.SetHeader([]string{"Username", "Email", "First Name", "Last Name", "ID", "Pin", "Subject ID"}) + table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false}) + table.SetCenterSeparator("|") + table.Append(userData) - table.Render() + table.Render() + } } }