diff --git a/internal/homesick/cli/cli.go b/internal/homesick/cli/cli.go index e2110ad..b0d4bc7 100644 --- a/internal/homesick/cli/cli.go +++ b/internal/homesick/cli/cli.go @@ -155,7 +155,9 @@ func (c *versionCmd) Run(app *core.App) error { return app.Version(version.String) } -type pullCmd struct{} +type pullCmd struct { + Castle string `arg:"" optional:"" name:"CASTLE" help:"Castle name."` +} type pushCmd struct{} @@ -177,16 +179,16 @@ type rcCmd struct { type generateCmd struct{} -func (c *pullCmd) Run() error { return notImplemented("pull") } -func (c *pushCmd) Run() error { return notImplemented("push") } -func (c *commitCmd) Run() error { return notImplemented("commit") } -func (c *destroyCmd) Run() error { return notImplemented("destroy") } -func (c *cdCmd) Run() error { return notImplemented("cd") } -func (c *openCmd) Run() error { return notImplemented("open") } -func (c *execCmd) Run() error { return notImplemented("exec") } -func (c *execAllCmd) Run() error { return notImplemented("exec_all") } -func (c *rcCmd) Run(app *core.App) error { return app.Rc(defaultCastle(c.Castle)) } -func (c *generateCmd) Run() error { return notImplemented("generate") } +func (c *pullCmd) Run(app *core.App) error { return app.Pull(defaultCastle(c.Castle)) } +func (c *pushCmd) Run() error { return notImplemented("push") } +func (c *commitCmd) Run() error { return notImplemented("commit") } +func (c *destroyCmd) Run() error { return notImplemented("destroy") } +func (c *cdCmd) Run() error { return notImplemented("cd") } +func (c *openCmd) Run() error { return notImplemented("open") } +func (c *execCmd) Run() error { return notImplemented("exec") } +func (c *execAllCmd) Run() error { return notImplemented("exec_all") } +func (c *rcCmd) Run(app *core.App) error { return app.Rc(defaultCastle(c.Castle)) } +func (c *generateCmd) Run() error { return notImplemented("generate") } func defaultCastle(castle string) string { if strings.TrimSpace(castle) == "" { diff --git a/internal/homesick/core/core.go b/internal/homesick/core/core.go index 1d11e65..549428a 100644 --- a/internal/homesick/core/core.go +++ b/internal/homesick/core/core.go @@ -133,6 +133,13 @@ func (a *App) Diff(castle string) error { return runGitWithIO(filepath.Join(a.ReposDir, castle), a.Stdout, a.Stderr, "diff") } +func (a *App) Pull(castle string) error { + if strings.TrimSpace(castle) == "" { + castle = "dotfiles" + } + return runGitWithIO(filepath.Join(a.ReposDir, castle), a.Stdout, a.Stderr, "pull") +} + func (a *App) Link(castle string) error { if strings.TrimSpace(castle) == "" { castle = "dotfiles"