@@ -32,37 +32,39 @@ func runContext(cmd *cobra.Command, args []string) error {
3232 branch , err := git .CurrentBranch ()
3333 if err != nil {
3434 shortHash := git .RunUnchecked ("rev-parse" , "--short" , "HEAD" )
35- fmt .Printf ("Branch: (detached HEAD at %s)\n " , shortHash )
35+ fmt .Printf ("%s (detached HEAD at %s)\n " , ui . LabelStyle . Render ( "Branch:" ), ui . HashStyle . Render ( shortHash ) )
3636 ui .PrintWarning ("You are in detached HEAD state." )
3737 } else {
38- fmt .Printf ("Branch: %s\n " , branch )
38+ fmt .Printf ("%s %s\n " , ui . LabelStyle . Render ( "Branch:" ), ui . BranchStyle . Render ( branch ) )
3939
4040 // Tracking
4141 tracking := git .RunUnchecked ("rev-parse" , "--abbrev-ref" , branch + "@{upstream}" )
4242 if tracking != "" {
4343 ahead , behind := git .AheadBehind (branch , tracking )
4444 if ahead == 0 && behind == 0 {
45- fmt .Printf ("Tracking: %s ( up to date)\n " , tracking )
45+ fmt .Printf ("%s %s %s \n " , ui . LabelStyle . Render ( "Tracking:" ), tracking , ui . DimStyle . Render ( "( up to date)" ) )
4646 } else {
4747 parts := ""
4848 if ahead > 0 {
49- parts += fmt .Sprintf ("%d ahead" , ahead )
49+ parts += ui . AddStyle . Render ( fmt .Sprintf ("%d ahead" , ahead ) )
5050 }
5151 if behind > 0 {
5252 if parts != "" {
5353 parts += ", "
5454 }
55- parts += fmt .Sprintf ("%d behind" , behind )
55+ parts += ui . DelStyle . Render ( fmt .Sprintf ("%d behind" , behind ) )
5656 }
57- fmt .Printf ("Tracking: %s (%s)\n " , tracking , parts )
57+ fmt .Printf ("%s %s (%s)\n " , ui . LabelStyle . Render ( "Tracking:" ) , tracking , parts )
5858 }
5959 }
6060
6161 // vs HEAD branch
6262 headBranch := git .HeadBranch ()
6363 if branch != headBranch {
6464 ahead , behind := git .AheadBehind (branch , headBranch )
65- fmt .Printf ("vs %s: %d ahead, %d behind\n " , headBranch , ahead , behind )
65+ aheadStr := ui .AddStyle .Render (fmt .Sprintf ("%d ahead" , ahead ))
66+ behindStr := ui .DelStyle .Render (fmt .Sprintf ("%d behind" , behind ))
67+ fmt .Printf ("%s %s, %s\n " , ui .LabelStyle .Render (fmt .Sprintf ("vs %s:" , headBranch )), aheadStr , behindStr )
6668 }
6769 }
6870
@@ -71,17 +73,17 @@ func runContext(cmd *cobra.Command, args []string) error {
7173 // Last commit
7274 _ , shortHash , message , _ , date := git .LastCommit ()
7375 if shortHash != "" {
74- fmt .Printf ("Last commit: %s \" %s\" (%s) \n " , shortHash , message , git .TimeAgo (date ))
76+ fmt .Printf ("%s %s \" %s\" %s \n " , ui . LabelStyle . Render ( "Last commit:" ), ui . HashStyle . Render ( shortHash ) , message , ui . DateStyle . Render ( "(" + git .TimeAgo (date ) + ")" ))
7577 } else {
76- fmt .Println ( " Last commit: No commits yet" )
78+ fmt .Printf ( "%s %s \n " , ui . LabelStyle . Render ( " Last commit:" ), ui . DimStyle . Render ( " No commits yet") )
7779 }
7880
7981 fmt .Println ()
8082
8183 // Working tree
8284 status := git .RunUnchecked ("status" , "--porcelain" )
8385 if status == "" {
84- fmt .Println ( " Working tree: clean" )
86+ fmt .Printf ( "%s %s \n " , ui . LabelStyle . Render ( " Working tree:" ), ui . SuccessStyle . Render ( " clean") )
8587 } else {
8688 modified , staged , untracked := 0 , 0 , 0
8789 for _ , line := range strings .Split (status , "\n " ) {
@@ -99,15 +101,15 @@ func runContext(cmd *cobra.Command, args []string) error {
99101 }
100102 }
101103 }
102- fmt .Println ("Working tree:" )
104+ fmt .Println (ui . LabelStyle . Render ( "Working tree:" ) )
103105 if modified > 0 {
104- fmt .Printf (" Modified: %d file%s\n " , modified , ui .Plural (modified ))
106+ fmt .Printf (" %s %s \n " , ui . LabelStyle . Render ( "Modified:" ), ui . WarningStyle . Render ( fmt . Sprintf ( " %d file%s" , modified , ui .Plural (modified )) ))
105107 }
106108 if staged > 0 {
107- fmt .Printf (" Staged: %d file%s\n " , staged , ui .Plural (staged ))
109+ fmt .Printf (" %s %s \n " , ui . LabelStyle . Render ( "Staged:" ), ui . AddStyle . Render ( fmt . Sprintf ( " %d file%s" , staged , ui .Plural (staged )) ))
108110 }
109111 if untracked > 0 {
110- fmt .Printf (" Untracked: %d file%s\n " , untracked , ui .Plural (untracked ))
112+ fmt .Printf (" %s %s \n " , ui . LabelStyle . Render ( " Untracked:" ), ui . DimStyle . Render ( fmt . Sprintf ( " %d file%s" , untracked , ui .Plural (untracked )) ))
111113 }
112114 }
113115
@@ -116,9 +118,9 @@ func runContext(cmd *cobra.Command, args []string) error {
116118 // Stash
117119 stashCount := git .StashCount ()
118120 if stashCount > 0 {
119- fmt .Printf ("Stash: %d entr%s\n " , stashCount , ui .PluralIES (stashCount ))
121+ fmt .Printf ("%s %d entr%s\n " , ui . LabelStyle . Render ( "Stash:" ) , stashCount , ui .PluralIES (stashCount ))
120122 } else {
121- fmt .Println ( "Stash: empty" )
123+ fmt .Printf ( "%s %s \n " , ui . LabelStyle . Render ( "Stash:" ), ui . DimStyle . Render ( " empty") )
122124 }
123125
124126 // Active operations
0 commit comments