diff --git a/cmd/signaldctl/cmd/group/preview/preview.go b/cmd/signaldctl/cmd/group/preview/preview.go index 43cf888..4f51e77 100644 --- a/cmd/signaldctl/cmd/group/preview/preview.go +++ b/cmd/signaldctl/cmd/group/preview/preview.go @@ -22,7 +22,9 @@ import ( "os" "strings" + "github.com/jedib0t/go-pretty/v6/table" "github.com/spf13/cobra" + "gopkg.in/yaml.v2" "gitlab.com/signald/signald-go/cmd/signaldctl/common" "gitlab.com/signald/signald-go/cmd/signaldctl/config" @@ -68,8 +70,30 @@ var ( } switch common.OutputFormat { - case common.OutputFormatJSON, common.OutputFormatDefault: + case common.OutputFormatJSON: return json.NewEncoder(os.Stdout).Encode(info) + case common.OutputFormatYAML: + return yaml.NewEncoder(os.Stdout).Encode(info) + case common.OutputFormatDefault, common.OutputFormatTable: + t := table.NewWriter() + t.SetOutputMirror(os.Stdout) + + joinApproval := "unknown" + switch info.AddFromInviteLink { + case 3: + joinApproval = "yes" + case 1: + joinApproval = "no" + } + + t.AppendRows([]table.Row{ + table.Row{"Title", info.Title}, + table.Row{"Group ID", info.GroupID}, + table.Row{"Member Count", info.MemberCount}, + table.Row{"Membership Approval", joinApproval}, + }) + common.StylizeTable(t) + t.Render() } return nil