diff --git a/DOCS.md b/DOCS.md index 6a259b5..755f67b 100644 --- a/DOCS.md +++ b/DOCS.md @@ -90,6 +90,7 @@ branch creates a new branch called `name` based on `base` ``` [--base,-b]=[value] [--help] +[--ide,-i] [--list,-l] [--no-fetch,-nf] ``` @@ -105,6 +106,9 @@ branch --base [ref=main] **--help**: Show help +**--ide,-i**: Open an IDE for the new branch + + **--list,-l**: List branches available diff --git a/cmd/branch.go b/cmd/branch.go index 0824ae5..532a232 100644 --- a/cmd/branch.go +++ b/cmd/branch.go @@ -20,6 +20,8 @@ func (h *Handler) Branch() *ffcli.Command { fs.StringVar(baseFlag, "b", *baseFlag, "--base") listFlag := fs.Bool("list", false, "List branches available") fs.BoolVar(listFlag, "l", *listFlag, "--list") + ideFlag := fs.Bool("ide", false, "Open an IDE for the new branch") + fs.BoolVar(ideFlag, "i", *ideFlag, "--ide") return &ffcli.Command{ Name: "branch", FlagSet: fs, @@ -58,7 +60,15 @@ func (h *Handler) Branch() *ffcli.Command { h.fetch(ctx) } - return h.run(ctx, "git", "worktree", "add", "-B", name, filepath.Join(h.Config.Workspace(), name), base) + if err := h.run(ctx, "git", "worktree", "add", "-B", name, filepath.Join(h.Config.Workspace(), name), base); err != nil { + return err + } + + if *ideFlag { + return h.IDE().ParseAndRun(ctx, []string{name}) + } + + return nil }, } }