Skip to content

Commit

Permalink
Added flag -g to enable glamour support
Browse files Browse the repository at this point in the history
  • Loading branch information
craftamap committed Jan 12, 2020
1 parent c81698a commit c3a64b0
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions cmd/issue_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ var issueShowCmd = &cobra.Command{
log.Fatal(err)
}

printIssue(issue, rn)
glamour_e, _ := cmd.Flags().GetBool("glamour")

printIssue(issue, rn, glamour_e)

showComments, _ := cmd.Flags().GetBool("comments")
if showComments {
Expand All @@ -43,7 +45,7 @@ var issueShowCmd = &cobra.Command{
},
}

func printIssue(issue *gitlab.Issue, project string) {
func printIssue(issue *gitlab.Issue, project string, glamour_enabled bool) {
milestone := "None"
timestats := "None"
dueDate := "None"
Expand All @@ -70,15 +72,18 @@ func printIssue(issue *gitlab.Issue, project string) {
assignees[i] = a.Username
}
}
r, _ := glamour.NewTermRenderer(
glamour.WithStandardStyle("dark"),
)

issue.Description, _ = r.Render(issue.Description)
if glamour_enabled {
r, _ := glamour.NewTermRenderer(
glamour.WithStandardStyle("dark"),
)

issue.Description, _ = r.Render(issue.Description)
}

fmt.Printf(`
#%d %s
###################################
===================================
%s
-----------------------------------
Project: %s
Expand Down Expand Up @@ -140,5 +145,6 @@ func init() {
issueShowCmd.MarkZshCompPositionalArgumentCustom(2, "__lab_completion_issue $words[2]")
issueShowCmd.MarkZshCompPositionalArgumentCustom(1, "__lab_completion_issue")
issueShowCmd.Flags().BoolP("comments", "c", false, "Show comments for the issue")
issueShowCmd.Flags().BoolP("glamour", "g", false, "Use glamour to print the issue description")
issueCmd.AddCommand(issueShowCmd)
}

0 comments on commit c3a64b0

Please sign in to comment.