initialize file structure

This commit is contained in:
Daveberry committed 2026-06-07 00:45:03 +08:00
commit 2b5c0dddc4
8 files changed
+154

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(pullCmd)
}
var pullCmd = &cobra.Command{
Use: "pull [source]",
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)
},
}
+24
View File
@@ -0,0 +1,24 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(pushCmd)
}
var pushCmd = &cobra.Command{
Use: "push [destination]",
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]
}
fmt.Printf("Pushing changes to: %s...\n", dest)
},
}
+26
View File
@@ -0,0 +1,26 @@
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "guh",
Short: "Guh is a modular CLI tool",
Long: `A comprehensive CLI tool built with Go and Cobra to demonstrate multi-command structures.`,
Run: func(cmd *cobra.Command, args []string) {
// This runs if no subcommand is provided
fmt.Println("Welcome to guh! Use --help to see available commands.")
},
}
// Execute adds all child commands to the root command and sets flags appropriately.
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
+45
View File
@@ -0,0 +1,45 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
// COMMAND LINE INTERFACE GOES HERE
func init() {
rootCmd.AddCommand(switchCmd)
switchCmd.AddCommand(switchBranchCmd)
switchCmd.AddCommand(switchAccountCmd)
}
var switchCmd = &cobra.Command{
Use: "switch",
Short: "Switch context, branches, or accounts",
}
var switchBranchCmd = &cobra.Command{
Use: "branch [name]",
Short: "Switch to a specific branch",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
performBranchSwitch(args[0])
},
}
var switchAccountCmd = &cobra.Command{
Use: "account [username]",
Short: "Switch to a specific user account",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
performAccountSwitch(args[0])
},
}
// PERFORMERS GO HERE
func performAccountSwitch(username string) {
fmt.Printf("Switched to account: %s\n", username)
}
func performBranchSwitch(branchName string) {
fmt.Printf("Switched to branch: %s\n", branchName)
}