branch w/o args shows branches, same with link

This commit is contained in:
daveberrys committed 2026-07-26 18:34:26 +08:00
1 parent cc1072a859
commit bfc5ddc820
3 files changed
+8 -8

No files matched your search

+5 -1
View File
@@ -5,6 +5,7 @@ package branch
import ( import (
"github.com/daveberrys/guh/src/cmd" "github.com/daveberrys/guh/src/cmd"
"github.com/daveberrys/guh/src/utils"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -18,5 +19,8 @@ func init() {
var branchCmd = &cobra.Command{ var branchCmd = &cobra.Command{
Use: "branch", Use: "branch",
Short: "Manage branches", Short: "Manage branches - No args given, lists all branches",
Run: func(c *cobra.Command, args []string) {
utils.RunGit(false, "branch")
},
} }
+2 -6
View File
@@ -15,12 +15,8 @@ var switchCmd = &cobra.Command{
Short: "Switch to a branch, or list branches with 'list'", Short: "Switch to a branch, or list branches with 'list'",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
RunE: func(c *cobra.Command, args []string) error { RunE: func(c *cobra.Command, args []string) error {
if args[0] == "list" { utils.RunGitSequence(false, []string{"switch", args[0]})
utils.RunGit(false, "branch") fmt.Printf("Switched to branch: %s\n", args[0])
} else {
utils.RunGitSequence(false, []string{"switch", args[0]})
fmt.Printf("Switched to branch: %s\n", args[0])
}
return nil return nil
}, },
} }
+1 -1
View File
@@ -17,7 +17,7 @@ func init() {
var linkCmd = &cobra.Command{ var linkCmd = &cobra.Command{
Use: "link", Use: "link",
Short: "Link repositories. Shows all linked repositories", Short: "Link repositories. Shows all linked repositories - No args given, lists all remotes.",
RunE: func(c *cobra.Command, args []string) error { RunE: func(c *cobra.Command, args []string) error {
utils.RunGit(false, "remote", "-v") utils.RunGit(false, "remote", "-v")
return nil return nil