commit 2b5c0dddc463f98c3d5087020254b0a6d2641377 Author: Daveberry <84567826+daveberrys@users.noreply.github.com> Date: Sun Jun 7 00:45:03 2026 +0800 initialize file structure diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..f865871 --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module github.com/daveberrys/guh + +go 1.26.3 + +require ( + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/spf13/cobra v1.10.2 // indirect + github.com/spf13/pflag v1.0.9 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..a6ee3e0 --- /dev/null +++ b/go.sum @@ -0,0 +1,10 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= +github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= +github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= +github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/main.go b/main.go new file mode 100644 index 0000000..6fdf94b --- /dev/null +++ b/main.go @@ -0,0 +1,9 @@ +package main + +import ( + "github.com/daveberrys/guh/src/cmd" +) + +func main() { + cmd.Execute() +} diff --git a/src/cmd/pull.go b/src/cmd/pull.go new file mode 100644 index 0000000..2176b04 --- /dev/null +++ b/src/cmd/pull.go @@ -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) + }, +} diff --git a/src/cmd/push.go b/src/cmd/push.go new file mode 100644 index 0000000..5a89485 --- /dev/null +++ b/src/cmd/push.go @@ -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) + }, +} diff --git a/src/cmd/root.go b/src/cmd/root.go new file mode 100644 index 0000000..741fd23 --- /dev/null +++ b/src/cmd/root.go @@ -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) + } +} diff --git a/src/cmd/switch.go b/src/cmd/switch.go new file mode 100644 index 0000000..4a42179 --- /dev/null +++ b/src/cmd/switch.go @@ -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) +} \ No newline at end of file diff --git a/src/utils/json.go b/src/utils/json.go new file mode 100644 index 0000000..f948682 --- /dev/null +++ b/src/utils/json.go @@ -0,0 +1,7 @@ +package utils + +import ("fmt") + +func init() { + fmt.Println("json read, save, delete logic goes here") +} \ No newline at end of file