Add ide flag to branch command
ci/woodpecker/push/goreleaser Pipeline was successful
Details
ci/woodpecker/push/goreleaser Pipeline was successful
Details
Signed-off-by: jolheiser <john.olheiser@gmail.com>main
parent
8d5ec322a3
commit
693c85ad18
4
DOCS.md
4
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] <name>
|
|||
**--help**: Show help
|
||||
|
||||
|
||||
**--ide,-i**: Open an IDE for the new branch
|
||||
|
||||
|
||||
**--list,-l**: List branches available
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue