Skip to content

Commit d786572

Browse files
authored
Merge pull request #256 from hkchekc/colorp
LScmd enhancement
2 parents 5ee1573 + 9999510 commit d786572

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

gincmd/lscmd.go

+29-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
ginclient "github.com/G-Node/gin-cli/ginclient"
1010
"github.com/G-Node/gin-cli/gincmd/ginerrors"
1111
"github.com/G-Node/gin-cli/git"
12+
"github.com/fatih/color"
1213
"github.com/spf13/cobra"
1314
)
1415

@@ -68,7 +69,34 @@ func lsRepo(cmd *cobra.Command, args []string) {
6869
// print each category with len(items) > 0 with appropriate header
6970
for _, status := range statuses {
7071
fmt.Printf("%s:\n", status.Description())
71-
fmt.Printf("\n\t%s\n\n", strings.Join(statFiles[status], "\n\t"))
72+
switch d := status; {
73+
case d == ginclient.Synced:
74+
fmt.Fprintf(color.Output, green("\n\t%s\n\n"), strings.Join(statFiles[status], "\n\t"))
75+
case d == ginclient.NoContent:
76+
fmt.Fprintf(color.Output, " (use \"gin get-content <file>...\" to download content)\n")
77+
fmt.Fprintf(color.Output, "\n\t%s\n\n", strings.Join(statFiles[status], "\n\t"))
78+
case d == ginclient.Modified:
79+
fmt.Fprintf(color.Output, " (use \"gin upload <file>...\" to upload changes\n")
80+
fmt.Fprintf(color.Output, " (use \"gin commit <file>...\" to save changes locally)\n")
81+
fmt.Fprintf(color.Output, yellow("\n\t%s\n\n"), strings.Join(statFiles[status], "\n\t"))
82+
case d == ginclient.LocalChanges:
83+
fmt.Fprintf(color.Output, " (use \"gin upload <file>...\" to upload changes)\n")
84+
fmt.Fprintf(color.Output, "\n\t%s\n\n", strings.Join(statFiles[status], "\n\t"))
85+
case d == ginclient.RemoteChanges:
86+
fmt.Fprintf(color.Output, " (use \"gin download <file>...\" to download changes)\n")
87+
fmt.Fprintf(color.Output, "\n\t%s\n\n", strings.Join(statFiles[status], "\n\t"))
88+
case d == ginclient.Unlocked:
89+
fmt.Fprintf(color.Output, " (use \"gin lock <file>...\" to lock file)\n")
90+
fmt.Fprintf(color.Output, "\n\t%s\n\n", strings.Join(statFiles[status], "\n\t"))
91+
case d == ginclient.Removed:
92+
fmt.Fprintf(color.Output, red("\n\t%s\n\n"), strings.Join(statFiles[status], "\n\t"))
93+
case d == ginclient.Untracked:
94+
fmt.Fprintf(color.Output, " (use \"gin upload <file>...\" to upload file and begin tracking)\n")
95+
fmt.Fprintf(color.Output, "\n\t%s\n\n", strings.Join(statFiles[status], "\n\t"))
96+
default:
97+
fmt.Fprintf(color.Output, "\n\t%s\n\n", strings.Join(statFiles[status], "\n\t"))
98+
}
99+
72100
}
73101
}
74102
}

0 commit comments

Comments
 (0)