77 "github.com/go-git/go-git/v5"
88 "github.com/go-git/go-git/v5/plumbing/transport/http"
99 "github.com/go-git/go-git/v5/plumbing/transport/ssh"
10- "github.com/mitchellh/colorstring"
1110 log "github.com/sirupsen/logrus"
1211 "github.com/spf13/cobra"
1312 "github.com/yodamad/heimdall/cmd/entity"
@@ -53,23 +52,23 @@ func listGitDirs() {
5352 answer := "n"
5453
5554 for interactiveMode && ! strings .EqualFold (answer , "y" ) {
56- answer = commons .AskQuestion (colorstring . Color ("🔍 Search in directory " + tui .PathColor + rootDir + "[default] [light_gray][Y/n][default] : " ), "Y" )
55+ answer = tui .AskQuestion (utils . ColorString ("🔍 Search in directory " + tui .PathColor + rootDir + "[default] [light_gray][Y/n][default] : " ), "Y" )
5756 if strings .EqualFold (answer , "n" ) {
5857 if strings .EqualFold (answer , "n" ) {
59- answer = commons .AskQuestion (colorstring . Color ("➡️ Directory to search in : " ), rootDir )
58+ answer = tui .AskQuestion (utils . ColorString ("➡️ Directory to search in : " ), rootDir )
6059 }
6160 rootDir = answer
6261 } else if answer == "" {
6362 answer = "y"
6463 } else if ! strings .EqualFold (answer , "y" ) {
65- fmt .Println (colorstring . Color ("[yellow]Unknown option value : [light_gray]" + answer ))
64+ fmt .Println (utils . ColorString ("[yellow]Unknown option value : [light_gray]" + answer ))
6665 // Reset answer
6766 answer = "n"
6867 }
6968 }
7069
7170 if ! interactiveMode {
72- utils .Trace (colorstring . Color ("🔍 Search in directory " + tui .PathColor + rootDir + "[default]" ), false )
71+ utils .Trace (utils . ColorString ("🔍 Search in directory " + tui .PathColor + rootDir + "[default]" ), false )
7372 }
7473
7574 // Initialize the spinner
@@ -83,9 +82,9 @@ func listGitDirs() {
8382 }
8483
8584 if rootDir == commons .DefaultWorkDir {
86- m .Text = colorstring . Color ("Searching in [bold]default directory[default] : " + tui .PathColor + "'" + rootDir + "'[default]" )
85+ m .Text = utils . ColorString ("Searching in [bold]default directory[default] : " + tui .PathColor + "'" + rootDir + "'[default]" )
8786 } else {
88- m .Text = colorstring . Color ("Searching in " + tui .PathColor + "'" + rootDir + "'[default] ..." )
87+ m .Text = utils . ColorString ("Searching in " + tui .PathColor + "'" + rootDir + "'[default] ..." )
8988 }
9089
9190 // Start the spinner
@@ -150,20 +149,20 @@ func checkDir(rootDir string, spinner *tea.Program) tea.Cmd {
150149 if nbGitFolders > 0 {
151150 utils .PrintTable (gitFolders )
152151 if nbSkippedFolders > 0 {
153- utils .Trace (colorstring . Color ("Found [green]" + strconv .Itoa (nbGitFolders )+ "[default] folder(s) (Skip [yellow]" + strconv .Itoa (nbSkippedFolders )+ "[default] folders because of errors, use '-v' to check in details)" ), false )
152+ utils .Trace (utils . ColorString ("Found [green]" + strconv .Itoa (nbGitFolders )+ "[default] folder(s) (Skip [yellow]" + strconv .Itoa (nbSkippedFolders )+ "[default] folders because of errors, use '-v' to check in details)" ), false )
154153 } else {
155- utils .Trace (colorstring . Color ("Found [green]" + strconv .Itoa (nbGitFolders )+ "[default] folder(s)" ), false )
154+ utils .Trace (utils . ColorString ("Found [green]" + strconv .Itoa (nbGitFolders )+ "[default] folder(s)" ), false )
156155 }
157156 if commons .Interactive {
158157 chooseInteractiveOption (spinner )
159158 }
160159 } else {
161160 if nbSkippedFolders > 0 {
162- utils .Trace (colorstring . Color ("😕 [red]No git folder found[default] (Skip [yellow]" + strconv .Itoa (nbSkippedFolders )+ "[default] folders because of errors, use '-v' to check in details)" ), false )
161+ utils .Trace (utils . ColorString ("😕 [red]No git folder found[default] (Skip [yellow]" + strconv .Itoa (nbSkippedFolders )+ "[default] folders because of errors, use '-v' to check in details)" ), false )
163162 } else {
164- utils .Trace (colorstring . Color ("😕 [red]No git folder found" ), false )
163+ utils .Trace (utils . ColorString ("😕 [red]No git folder found" ), false )
165164 }
166- utils .Trace (colorstring . Color ("🤔 Is " + tui .PathColor + rootDir + "[default] the correct path ?" ), false )
165+ utils .Trace (utils . ColorString ("🤔 Is " + tui .PathColor + rootDir + "[default] the correct path ?" ), false )
167166 }
168167
169168 return tea .Quit
@@ -228,7 +227,7 @@ func chooseInteractiveOption(spinner *tea.Program) {
228227 choices = append (choices , "📥 Display remote commits of a repository" )
229228 }
230229 if checkIfAtLeastOne (gitFolders , func (folder entity.GitFolder ) bool { return entity .CanPull (folder ) }) {
231- choices = append (choices , colorstring . Color ("🔃 Update one or several repositories ([dim]git pull[reset])" ))
230+ choices = append (choices , utils . ColorString ("🔃 Update one or several repositories ([dim]git pull[reset])" ))
232231 }
233232 choices = append (choices , "✅ I'm done" )
234233
@@ -249,11 +248,11 @@ func chooseInteractiveOption(spinner *tea.Program) {
249248 utils .PrintSeparation ()
250249 folder := pickSingleItem (gitFolders , func (folder entity.GitFolder ) bool { return entity .HasRemoteChanges (folder ) })
251250 listRemoteChanges (folder )
252- case colorstring . Color ("🔃 Update one or several repositories ([dim]git pull[reset])" ):
251+ case utils . ColorString ("🔃 Update one or several repositories ([dim]git pull[reset])" ):
253252 toUpdate := selectItems (gitFolders , func (folder entity.GitFolder ) bool { return entity .CanPull (folder ) })
254253 utils .PrintSeparation ()
255254 if len (toUpdate ) > 0 {
256- utils .Trace (colorstring . Color (tui .TitleColor + "Pulling repositories :[default]\n " ), false )
255+ utils .Trace (utils . ColorString (tui .TitleColor + "Pulling repositories :[default]\n " ), false )
257256 }
258257 for _ , folder := range toUpdate {
259258 gitPull (folder )
@@ -290,7 +289,7 @@ func listLocalChanges(path string, spinner *tea.Program) {
290289 w , _ := repo .Worktree ()
291290 s , _ := w .Status ()
292291
293- utils .Trace (colorstring . Color ("🚦 [dark_gray]" + strconv .Itoa (len (s ))+ " files" ), false )
292+ utils .Trace (utils . ColorString ("🚦 [dark_gray]" + strconv .Itoa (len (s ))+ " files" ), false )
294293 for filename , _ := range s {
295294 fileStatus := s .File (filename )
296295 fmt .Printf ("%s - %s \n " , filename , string (fileStatus .Worktree ))
@@ -305,7 +304,7 @@ func listRemoteChanges(gitFolder string) {
305304
306305 fullOutput := string (out )
307306
308- utils .Trace (colorstring . Color ("🚦 [dark_gray]" + strconv .Itoa (strings .Count (fullOutput , "\n " ))+ " commits" ), false )
307+ utils .Trace (utils . ColorString ("🚦 [dark_gray]" + strconv .Itoa (strings .Count (fullOutput , "\n " ))+ " commits" ), false )
309308 utils .Trace (string (out ), false )
310309}
311310
@@ -340,7 +339,7 @@ func pickSingleItem(items []entity.GitFolder, fn filterFolder) string {
340339
341340func selectItems (items []entity.GitFolder , fn filterFolder ) []entity.GitFolder {
342341 utils .PrintSeparation ()
343- var q = colorstring . Color (tui .TitleColor + "Pick repositories to update:[default]" )
342+ var q = utils . ColorString (tui .TitleColor + "Pick repositories to update:[default]" )
344343
345344 var filteredItems []entity.GitFolder
346345 for _ , item := range items {
@@ -405,7 +404,7 @@ func gitPull(folder entity.GitFolder) {
405404 worktree , _ := repo .Worktree ()
406405 err := worktree .Pull (& git.PullOptions {RemoteName : "origin" })
407406 if err != nil {
408- utils .TraceWarn (colorstring . Color ("Cannot pull : [red]" + err .Error ()))
407+ utils .TraceWarn (utils . ColorString ("Cannot pull : [red]" + err .Error ()))
409408 }
410- utils .Trace (colorstring . Color ("✅ [bold]" + folder .Path + "[reset] pulled" ), false )
409+ utils .Trace (utils . ColorString ("✅ [bold]" + folder .Path + "[reset] pulled" ), false )
411410}
0 commit comments