Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "pretty", Short: "Parallel remote execution tty", Long: `Parallel remote execution tty - (Yet another parallel ssh/shell) usage: pretty <host1> <host2> <host3>... `, Args: func(cmd *cobra.Command, args []string) error { if len(args) < 1 && hostGroup == "" && hostsFile == "" { return errors.New("requires at least one host, hostGroup ou hostsFile") } return nil }, Run: func(cmd *cobra.Command, args []string) { if hostGroup != "" && len(args) > 1 { toAppend := viper.GetStringSlice(fmt.Sprintf("groups.%s", hostGroup)) args = append(args, toAppend...) } else if hostGroup != "" && len(args) < 1 { args = viper.GetStringSlice(fmt.Sprintf("groups.%s", hostGroup)) } if hostsFile != "" { data, err := ioutil.ReadFile(hostsFile) if err != nil { fmt.Printf("unable to read hostsFile: %v\n", err) os.Exit(1) } for _, host := range strings.Split(string(data), "\n") { if host == "" { continue } args = append(args, strings.TrimSpace(host)) } } var colors = []color.Attribute{ color.FgRed, color.FgGreen, color.FgYellow, color.FgBlue, color.FgMagenta, color.FgCyan, color.FgWhite, color.FgHiRed, color.FgHiGreen, color.FgHiYellow, color.FgHiBlue, color.FgHiMagenta, color.FgHiCyan, color.FgHiWhite, } for len(colors) <= len(args) { colors = append(colors, colors...) } hostList := sshConn.NewHostList() for pos, hostname := range args { host := &sshConn.Host{ Hostname: hostname, Color: color.New(colors[pos%len(colors)]), } hostList.AddHost(host) } shell.Spawn(hostList) }, }
RootCmd represents the base command when called without any subcommands
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.