mirror of
https://github.com/daveberrys/guh.git
synced 2026-11-29 00:26:46 +08:00
add deleting branch, editing account via editor
This commit is contained in:
1 parent
6ba9baaecd
commit
2e91a67c8f
4 files changed
+54
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/daveberrys/guh/src/utils"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var editCmd = &cobra.Command{
|
||||
Use: "edit",
|
||||
Short: "Opens up a code editor, and opens accounts.json file",
|
||||
Args: cobra.ExactArgs(0),
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
path, _ := utils.AccountsFilePath()
|
||||
editors := []string{"nano", "code", "zed", "zeditor", "vi", "vim", "emacs", "notepad.exe"}
|
||||
// editors := []string{"this", "is", "a", "_test", "for", "fail"}
|
||||
for _, editor := range editors {
|
||||
if _, err := exec.Command(editor, path).Output(); err == nil {
|
||||
fmt.Printf("Opening editor: %s\n", editor)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("No supported editors found")
|
||||
fmt.Println("Here are the supported editors we have;")
|
||||
fmt.Println(strings.Join(editors, ", "))
|
||||
// for _, editor := range editors { fmt.Println("- " + editor) }
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -9,6 +9,7 @@ func init() {
|
||||
cmd.RootCmd.AddCommand(accountCmd)
|
||||
accountCmd.AddCommand(saveCmd)
|
||||
accountCmd.AddCommand(switchCmd)
|
||||
accountCmd.AddCommand(editCmd)
|
||||
}
|
||||
|
||||
var accountCmd = &cobra.Command{
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package branch
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/daveberrys/guh/src/utils"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var deleteCmd = &cobra.Command{
|
||||
Use: "delete [name]",
|
||||
Short: "Delete a branch",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
utils.RunGitSequence(false, []string{"branch", "-D", args[0]})
|
||||
fmt.Printf("Deleted branch: %s\n", args[0])
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -10,6 +10,7 @@ func init() {
|
||||
branchCmd.AddCommand(createCmd)
|
||||
branchCmd.AddCommand(switchCmd)
|
||||
branchCmd.AddCommand(renameCmd)
|
||||
branchCmd.AddCommand(deleteCmd)
|
||||
}
|
||||
|
||||
var branchCmd = &cobra.Command{
|
||||
|
||||
Reference in new issue
Block a user