refactor: use diff instead of compare
parent
031091c978
commit
d5929acd01
|
@ -20,6 +20,6 @@ go build ./cmd/dot
|
|||
|
||||
## Roadmap
|
||||
|
||||
- [ ] Support compare directory
|
||||
- [x] Switch to use lua for neovim config
|
||||
- [x] Add diff command
|
||||
- [x] Support diff directory
|
||||
|
|
|
@ -68,16 +68,16 @@ func (a *action) runClean(c *cli.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (a *action) runCompare(c *cli.Context) error {
|
||||
func (a *action) runDiff(c *cli.Context) error {
|
||||
a.getFlags(c)
|
||||
a.log("start %s\n", compareCommand)
|
||||
a.log("start %s\n", diffCommand)
|
||||
|
||||
cfg, err := a.loadConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := cfg.Compare(); err != nil {
|
||||
if err := cfg.Diff(); err != nil {
|
||||
return fmt.Errorf("failed to compare config: %w", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ const (
|
|||
installCommand = "install"
|
||||
updateCommand = "update"
|
||||
cleanCommand = "clean"
|
||||
compareCommand = "compare"
|
||||
diffCommand = "diff"
|
||||
|
||||
// flag usages
|
||||
verboseUsage = "show what is going on"
|
||||
|
@ -31,7 +31,7 @@ const (
|
|||
installUsage = "install user configs from dotfiles"
|
||||
updateUsage = "update dotfiles from user configs"
|
||||
cleanUsage = "clean unused dotfiles"
|
||||
compareUsage = "compare dotfiles with user configs"
|
||||
diffUsage = "diff dotfiles with user configs"
|
||||
|
||||
currentDir = "."
|
||||
)
|
||||
|
@ -41,7 +41,6 @@ var (
|
|||
installAliases = []string{"i"}
|
||||
updateAliases = []string{"u"}
|
||||
cleanAliases = []string{"c"}
|
||||
compareAliases = []string{"cmp", "diff"}
|
||||
)
|
||||
|
||||
// denyOSes contains OS which is not supported
|
||||
|
@ -110,16 +109,15 @@ func NewApp() *App {
|
|||
Action: a.runClean,
|
||||
},
|
||||
{
|
||||
Name: compareCommand,
|
||||
Aliases: compareAliases,
|
||||
Usage: compareUsage,
|
||||
Name: diffCommand,
|
||||
Usage: diffUsage,
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: verboseFlag,
|
||||
Usage: verboseUsage,
|
||||
},
|
||||
},
|
||||
Action: a.runCompare,
|
||||
Action: a.runDiff,
|
||||
},
|
||||
},
|
||||
Action: a.runHelp,
|
||||
|
|
|
@ -16,7 +16,7 @@ type Config interface {
|
|||
Install() error
|
||||
Update() error
|
||||
Clean() error
|
||||
Compare() error
|
||||
Diff() error
|
||||
}
|
||||
|
||||
type configApps struct {
|
||||
|
|
|
@ -41,6 +41,6 @@ func (c *configDemo) Clean() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *configDemo) Compare() error {
|
||||
func (c *configDemo) Diff() error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ func (c *configReal) Clean() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *configReal) Compare() error {
|
||||
func (c *configReal) Diff() error {
|
||||
for _, app := range c.Apps {
|
||||
for _, p := range app.Paths {
|
||||
if err := diff.Diff(p.Internal, p.External); err != nil {
|
||||
|
|
Loading…
Reference in New Issue