Skip to content

Commit

Permalink
More output cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Aug 6, 2019
1 parent 1216b1c commit c2db7d5
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions output/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,9 @@ func (l *Output) shouldLogDotfile(dotfile *installer.PreparedDotfile) bool {
// DryrunInstall outputs the logging of a dryrun of the prepared dotfiles
func (l *Output) DryrunInstall() {
l.InstallInfo()
fmt.Println()

for _, dotfile := range l.PreparedInstall.Dotfiles {
l.DotfileInfo(dotfile)
}

fmt.Println()
}

// InstallInfo outputs details about the pending installation. Output is only
Expand All @@ -74,13 +70,14 @@ func (l *Output) InstallInfo() {
"%s %s added %s removed %s modified %s error\n",
color.HiBlackString("legend:"),
color.HiGreenString("◼️"),
color.HiYellowString("◼️"),
color.HiBlueString("◼️"),
color.HiRedString("◼️"),
color.HiBlueString("◼️"),
color.HiRedString("⨉"),
)

fmt.Printf("%s %s\n", color.HiBlackString("source:"), l.SourceConfig.SourcePath)
fmt.Printf("%s %s\n", color.HiBlackString("target:"), l.SourceConfig.InstallPath)
fmt.Println()
}

// DotfileInfo outputs information about a single prepared dotfile. Will not
Expand All @@ -95,25 +92,24 @@ func (l *Output) DotfileInfo(dotfile *installer.PreparedDotfile) {
return
}

indicatorColor := color.New()
indicator := "◼️"
indicatorColor := color.New()

switch {
case dotfile.PrepareError != nil:
indicator = "⨉"
indicatorColor.Add(color.FgRed)
case dotfile.IsNew:
indicatorColor.Add(color.FgHiGreen)
case dotfile.Removed:
indicatorColor.Add(color.FgHiYellow)
indicatorColor.Add(color.FgHiRed)
case dotfile.IsChanged():
indicatorColor.Add(color.FgBlue)
default:
indicatorColor.Add(color.FgHiBlack)
indicator = "-"
indicatorColor.Add(color.FgHiBlack)
}

fmt.Printf(" %s ", indicatorColor.Sprint(indicator))

group := ""
if len(dotfile.Sources) == 1 {
group = dotfile.Sources[0].Group
Expand All @@ -134,8 +130,13 @@ func (l *Output) DotfileInfo(dotfile *installer.PreparedDotfile) {
color.HiBlackString("]"),
)

output := fmt.Sprintf("%%-%ds %%s\n", l.maxDotfileLength+1)
fmt.Printf(output, dotfile.Path, group)
output := fmt.Sprintf(" %%s %%-%ds %%s\n", l.maxDotfileLength+1)
fmt.Printf(
output,
indicatorColor.Sprint(indicator),
dotfile.Path,
group,
)

if dotfile.PrepareError != nil {
fmt.Printf(" %s", color.RedString(dotfile.PrepareError.Error()))
Expand Down

0 comments on commit c2db7d5

Please sign in to comment.