From b727756a13d42836582c188cde33a78e9e5ab4ff Mon Sep 17 00:00:00 2001 From: Sig Lange Date: Sat, 3 Dec 2022 09:32:41 -0800 Subject: [PATCH] rename to clean --- cleanup.go => clean.go | 10 +++++----- config.go | 1 + link.go | 8 ++++++++ main.go | 8 ++++---- 4 files changed, 18 insertions(+), 9 deletions(-) rename cleanup.go => clean.go (85%) diff --git a/cleanup.go b/clean.go similarity index 85% rename from cleanup.go rename to clean.go index bdd3d35..03e1b8e 100644 --- a/cleanup.go +++ b/clean.go @@ -6,15 +6,15 @@ import ( "github.com/urfave/cli/v2" ) -type Cleanup struct { +type Clean struct { ctx *Context } -func (me *Cleanup) Flags() []cli.Flag { +func (me *Clean) Flags() []cli.Flag { return []cli.Flag{} } -func (me *Cleanup) Run(c *cli.Context) error { +func (me *Clean) Run(c *cli.Context) error { configfiles := me.ctx.getConfigFiles(c) for _, filename := range configfiles { @@ -27,7 +27,7 @@ func (me *Cleanup) Run(c *cli.Context) error { return nil } -func (me *Cleanup) RunFile(path string) error { +func (me *Clean) RunFile(path string) error { log.Tracef("runfile %s", path) cfg := GetDefaultConfig() err := cfg.LoadYaml(path) @@ -40,7 +40,7 @@ func (me *Cleanup) RunFile(path string) error { return me.RunConfig(cfg) } -func (me *Cleanup) RunConfig(cfg *AppConfig) error { +func (me *Clean) RunConfig(cfg *AppConfig) error { run, err := CompileRun(cfg.Symlinks, cfg.Script) if err != nil { diff --git a/config.go b/config.go index 4131b37..84b3408 100644 --- a/config.go +++ b/config.go @@ -10,6 +10,7 @@ import ( // main configuration structure type AppConfig struct { + Clean []string `yaml:"clean"` Mkdirs []string `yaml:"mkdirs"` Symlinks map[string]string `yaml:"symlinks"` Script []*Script `yaml:"script"` diff --git a/link.go b/link.go index 1d55d38..2d0b864 100644 --- a/link.go +++ b/link.go @@ -96,6 +96,10 @@ func (me *Link) RunConfig(opts *LinkOptions, cfg *AppConfig) error { if err != nil { return err } + err = CleanLinks(opts, run) + if err != nil { + return err + } return nil } @@ -236,3 +240,7 @@ func RunScripts(opts *LinkOptions, run *Run, stype string) error { return nil } + +func CleanLinks(opts *LinkOptions, run *Run) error { + return nil +} diff --git a/main.go b/main.go index 3b566b2..5faef4f 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,7 @@ func main() { link := &Link{ctx} unlink := &Unlink{ctx} status := &Status{ctx} - cleanup := &Cleanup{ctx} + clean := &Clean{ctx} app := &cli.App{ Name: "dotbot", @@ -66,10 +66,10 @@ func main() { Flags: status.Flags(), }) ctx.addCommand(&cli.Command{ - Name: "cleanup", + Name: "clean", Usage: "show unreferenced files", - Action: cleanup.Run, - Flags: cleanup.Flags(), + Action: clean.Run, + Flags: clean.Flags(), }) app.Run(os.Args) }