From 3e87fa0d53d78810c37e316d18d4fae1cea55718 Mon Sep 17 00:00:00 2001 From: Daveberry <84567826+daveberrys@users.noreply.github.com> Date: Tue, 9 Jun 2026 13:47:40 +0800 Subject: [PATCH] switch accounts, pull, push. --- src/cmd/pull.go | 20 +++++++++++++------- src/cmd/push.go | 12 ++++++++---- src/cmd/save.go | 31 +++++++++++++++++++++++++++++++ src/cmd/switch.go | 2 +- 4 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 src/cmd/save.go diff --git a/src/cmd/pull.go b/src/cmd/pull.go index 2176b04..3022aba 100644 --- a/src/cmd/pull.go +++ b/src/cmd/pull.go @@ -2,7 +2,9 @@ package cmd import ( "fmt" - + "os/exec" + "os" + "github.com/spf13/cobra" ) @@ -15,10 +17,14 @@ var pullCmd = &cobra.Command{ Short: "Pull updates from a source", Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - source := "default" - if len(args) > 0 { - source = args[0] - } - fmt.Printf("Pulling data from: %s...\n", source) - }, + + out, err := exec.Command("git", "fetch").CombinedOutput() + if err != nil { fmt.Fprintf(os.Stderr, "error: %s\n", err) } + + out, err = exec.Command("git", "pull").CombinedOutput() + if err != nil { fmt.Fprintf(os.Stderr, "error: %s\n", err) } + + fmt.Print(string(out)) +}, + } diff --git a/src/cmd/push.go b/src/cmd/push.go index 5a89485..2e3cfab 100644 --- a/src/cmd/push.go +++ b/src/cmd/push.go @@ -2,6 +2,8 @@ package cmd import ( "fmt" + "os" + "os/exec" "github.com/spf13/cobra" ) @@ -15,10 +17,12 @@ var pushCmd = &cobra.Command{ Short: "Push changes to a destination", Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - dest := "origin" - if len(args) > 0 { - dest = args[0] - } + dest := "main" + if len(args) > 0 { dest = args[0] } fmt.Printf("Pushing changes to: %s...\n", dest) + + out, err := exec.Command("git", "push", "origin", dest).CombinedOutput() + if err != nil { fmt.Fprintf(os.Stderr, "error: %s\n", err) } + fmt.Print(string(out)) }, } diff --git a/src/cmd/save.go b/src/cmd/save.go new file mode 100644 index 0000000..fdf80fe --- /dev/null +++ b/src/cmd/save.go @@ -0,0 +1,31 @@ +package cmd + +import ( + "fmt" + "github.com/spf13/cobra" +) + +// COMMAND LINE INTERFACE GOES HERE +func init() { + rootCmd.AddCommand(saveCmd) + saveCmd.AddCommand(accountSaveCmd) +} + +var saveCmd = &cobra.Command{ + Use: "save", + Short: "Save accounts,", +} + +var accountSaveCmd = &cobra.Command{ + Use: "account [username]", + Short: "Save a specific user account", + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + performAccountSave(args[0]) + }, +} + +// PERFORMERS GO HERE +func performAccountSave(username string) { + fmt.Printf("Saved account: %s\n", username) +} \ No newline at end of file diff --git a/src/cmd/switch.go b/src/cmd/switch.go index 4a42179..2378e7d 100644 --- a/src/cmd/switch.go +++ b/src/cmd/switch.go @@ -14,7 +14,7 @@ func init() { var switchCmd = &cobra.Command{ Use: "switch", - Short: "Switch context, branches, or accounts", + Short: "Switch branches or accounts", } var switchBranchCmd = &cobra.Command{