gosick #1
@@ -163,7 +163,10 @@ type pushCmd struct {
|
||||
Castle string `arg:"" optional:"" name:"CASTLE" help:"Castle name."`
|
||||
}
|
||||
|
||||
type commitCmd struct{}
|
||||
type commitCmd struct {
|
||||
Message string `short:"m" required:"" name:"MESSAGE" help:"Commit message."`
|
||||
Castle string `arg:"" optional:"" name:"CASTLE" help:"Castle name."`
|
||||
}
|
||||
|
||||
type destroyCmd struct{}
|
||||
|
||||
@@ -183,7 +186,9 @@ type generateCmd struct{}
|
||||
|
||||
func (c *pullCmd) Run(app *core.App) error { return app.Pull(defaultCastle(c.Castle)) }
|
||||
func (c *pushCmd) Run(app *core.App) error { return app.Push(defaultCastle(c.Castle)) }
|
||||
func (c *commitCmd) Run() error { return notImplemented("commit") }
|
||||
func (c *commitCmd) Run(app *core.App) error {
|
||||
return app.Commit(defaultCastle(c.Castle), c.Message)
|
||||
}
|
||||
func (c *destroyCmd) Run() error { return notImplemented("destroy") }
|
||||
func (c *cdCmd) Run() error { return notImplemented("cd") }
|
||||
func (c *openCmd) Run() error { return notImplemented("open") }
|
||||
|
||||
@@ -147,6 +147,24 @@ func (a *App) Push(castle string) error {
|
||||
return runGitWithIO(filepath.Join(a.ReposDir, castle), a.Stdout, a.Stderr, "push")
|
||||
}
|
||||
|
||||
func (a *App) Commit(castle string, message string) error {
|
||||
if strings.TrimSpace(castle) == "" {
|
||||
castle = "dotfiles"
|
||||
}
|
||||
|
||||
trimmedMessage := strings.TrimSpace(message)
|
||||
if trimmedMessage == "" {
|
||||
return errors.New("commit requires message")
|
||||
}
|
||||
|
||||
castledir := filepath.Join(a.ReposDir, castle)
|
||||
if err := runGitWithIO(castledir, a.Stdout, a.Stderr, "add", "--all"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return runGitWithIO(castledir, a.Stdout, a.Stderr, "commit", "-m", trimmedMessage)
|
||||
}
|
||||
|
||||
func (a *App) Link(castle string) error {
|
||||
if strings.TrimSpace(castle) == "" {
|
||||
castle = "dotfiles"
|
||||
|
||||
Reference in New Issue
Block a user