Add ide flag to branch command
ci/woodpecker/push/goreleaser Pipeline was successful Details

Signed-off-by: jolheiser <john.olheiser@gmail.com>
main
jolheiser 2022-09-04 22:09:49 -05:00
parent 8d5ec322a3
commit 693c85ad18
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
2 changed files with 15 additions and 1 deletions

View File

@ -90,6 +90,7 @@ branch creates a new branch called `name` based on `base`
``` ```
[--base,-b]=[value] [--base,-b]=[value]
[--help] [--help]
[--ide,-i]
[--list,-l] [--list,-l]
[--no-fetch,-nf] [--no-fetch,-nf]
``` ```
@ -105,6 +106,9 @@ branch --base [ref=main] <name>
**--help**: Show help **--help**: Show help
**--ide,-i**: Open an IDE for the new branch
**--list,-l**: List branches available **--list,-l**: List branches available

View File

@ -20,6 +20,8 @@ func (h *Handler) Branch() *ffcli.Command {
fs.StringVar(baseFlag, "b", *baseFlag, "--base") fs.StringVar(baseFlag, "b", *baseFlag, "--base")
listFlag := fs.Bool("list", false, "List branches available") listFlag := fs.Bool("list", false, "List branches available")
fs.BoolVar(listFlag, "l", *listFlag, "--list") 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{ return &ffcli.Command{
Name: "branch", Name: "branch",
FlagSet: fs, FlagSet: fs,
@ -58,7 +60,15 @@ func (h *Handler) Branch() *ffcli.Command {
h.fetch(ctx) 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
}, },
} }
} }