import ( "github.com/Around25/shellbot/logger" "github.com/Around25/shellbot/ops" "github.com/spf13/cobra" ) // shellCmd represents the shell command var shellCmd = &cobra.Command{ Use: "shell", Short: "Connect to a single server through ssh", Long: `Using shell you can connect open a ssh session to a server.`, Run: func(cmd *cobra.Command, args []string) { var name string if len(args) == 0 { logger.Fatal("Specify the name of the server you want to connect to.") } // get the name of the server as the first argument name = args[0] err := ops.OpenTerminalToServer(name, ops.NewConfig(AppConfig)) if err != nil { logger.Fatal(err) } }, } func init() { RootCmd.AddCommand(shellCmd) }
package cmd import ( "github.com/Around25/shellbot/logger" "github.com/Around25/shellbot/ops" "github.com/spf13/cobra" ) // copyCmd represents the copy command var copyCmd = &cobra.Command{ Use: "copy", Short: "Copy a file or directory between the local environment and a specified server", Long: `Copy a file or directory between the local environment and a specified server`, Run: func(cmd *cobra.Command, args []string) { err := ops.Copy(args[0], args[1], ops.NewConfig(AppConfig)) if err != nil { logger.Fatal(err) } }, } func init() { RootCmd.AddCommand(copyCmd) }
import ( "github.com/Around25/shellbot/logger" "github.com/Around25/shellbot/ops" "github.com/spf13/cobra" ) // setupCmd represents the setup command var setupCmd = &cobra.Command{ Use: "setup", Short: "Execute all the tasks associated with each group of servers", Long: `Execute all the tasks associated with each group of servers`, Run: func(cmd *cobra.Command, args []string) { var name string if len(args) == 0 { logger.Fatal("No environment specified") } name = args[0] err := ops.ProvisionEnvironment(name, ops.NewConfig(AppConfig)) if err != nil { logger.Fatal(err) } }, } func init() { RootCmd.AddCommand(setupCmd) }