Skip to content

Commit c9f036d

Browse files
committed
Expand verbose output
1 parent c2db7d5 commit c9f036d

File tree

2 files changed

+39
-12
lines changed

2 files changed

+39
-12
lines changed

cmd/dots/install.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ var installCmd = cobra.Command{
1515
forceReInstall, _ := cmd.Flags().GetBool("reinstall")
1616
verbose, _ := cmd.Flags().GetBool("verbose")
1717
dryRun, _ := cmd.Flags().GetBool("dry-run")
18-
info, _ := cmd.Flags().GetBool("info")
1918

2019
dotfiles := resolver.ResolveDotfiles(*sourceConfig, *sourceLockfile).Filter(args)
2120
prepared := installer.PrepareDotfiles(dotfiles, *sourceConfig)
@@ -31,7 +30,6 @@ var installCmd = cobra.Command{
3130
InstallConfig: installConfig,
3231
PreparedInstall: prepared,
3332
IsVerbose: verbose,
34-
IsInfo: info || verbose || dryRun,
3533
})
3634

3735
if dryRun {
@@ -55,7 +53,6 @@ func init() {
5553
flags.SortFlags = false
5654

5755
flags.BoolP("reinstall", "r", false, "forces execution of all installation scripts")
58-
flags.BoolP("info", "i", false, "prints install operation details")
59-
flags.BoolP("verbose", "v", false, "prints debug data, implies info")
60-
flags.BoolP("dry-run", "n", false, "do not mutate any dotfiles, implies info")
56+
flags.BoolP("verbose", "v", false, "prints debug data")
57+
flags.BoolP("dry-run", "n", false, "do not mutate any dotfiles, implies verbose")
6158
}

output/logger.go

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ import (
99
"go.evanpurkhiser.com/dots/installer"
1010
)
1111

12+
var e = color.RedString("errs:")
13+
var w = color.YellowString("warn:")
14+
var n = color.CyanString("note:")
15+
1216
// Config is a object used to configure the output logger.
1317
type Config struct {
1418
SourceConfig config.SourceConfig
1519
InstallConfig installer.InstallConfig
1620
PreparedInstall installer.PreparedInstall
1721
IsVerbose bool
18-
IsInfo bool
1922
}
2023

2124
// New creates a output logger given a configuration.
@@ -84,7 +87,7 @@ func (l *Output) InstallInfo() {
8487
// output anything without IsInfo. When IsVerbose is enabled additional
8588
// information about the prepared dotfile will be included.
8689
func (l *Output) DotfileInfo(dotfile *installer.PreparedDotfile) {
87-
if !l.IsInfo {
90+
if !l.IsVerbose {
8891
return
8992
}
9093

@@ -130,21 +133,48 @@ func (l *Output) DotfileInfo(dotfile *installer.PreparedDotfile) {
130133
color.HiBlackString("]"),
131134
)
132135

133-
output := fmt.Sprintf(" %%s %%-%ds %%s\n", l.maxDotfileLength+1)
136+
output := fmt.Sprintf(" %%s %%-%ds %%s", l.maxDotfileLength+1)
134137
fmt.Printf(
135138
output,
136139
indicatorColor.Sprint(indicator),
137140
dotfile.Path,
138141
group,
139142
)
140143

144+
if dotfile.Permissions.IsChanged() {
145+
fmt.Printf(
146+
" [%s %s %s]",
147+
color.New(color.FgHiRed).Sprintf("%#o", int(dotfile.Permissions.Old)),
148+
color.HiWhiteString("→"),
149+
color.New(color.FgHiGreen).Sprintf("%#o", int(dotfile.Permissions.New)),
150+
)
151+
}
152+
153+
ln(n, dotfile.Mode.Old.String())
154+
155+
ln := func(v ...interface{}) {
156+
fmt.Printf(" %s %s\n", v...)
157+
}
158+
159+
fmt.Println()
160+
141161
if dotfile.PrepareError != nil {
142-
fmt.Printf(" %s", color.RedString(dotfile.PrepareError.Error()))
162+
ln(e, color.HiRedString(dotfile.PrepareError.Error()))
143163
}
144164

145-
if !l.IsVerbose {
146-
return
165+
if dotfile.SourcesAreIrregular {
166+
ln(e, "source files are irregular")
167+
}
168+
169+
if dotfile.OverwritesExisting {
170+
ln(w, "ovewriting existing file")
171+
}
172+
173+
if dotfile.SourcePermissionsDiffer {
174+
ln(w, "inconsistent source file permissions")
147175
}
148176

149-
// TODO: Implement all verbosity outputs here
177+
if dotfile.RemovedNull {
178+
ln(n, "nothing to remove")
179+
}
150180
}

0 commit comments

Comments
 (0)