Exemple #1
0
func (r *recordCmd) ListCmds(cmdset string) {
	fmt.Printf("The following commands are in %s:\n", cmdset)
	fmt.Println("=========================================")

	d := data.NewCmdSetData()
	cmds := d.GetCmdSet(cmdset)

	for _, cmd := range cmds {
		fmt.Println(cmd)
	}
	fmt.Println()
}
Exemple #2
0
func (r *recordCmd) ListCmdSets() {
	fmt.Println("The following command sets are available:")
	fmt.Println("=========================================")

	d := data.NewCmdSetData()
	cmdsets := d.ListCmdSetNames()

	for _, name := range cmdsets {
		fmt.Println(name)
	}
	fmt.Println()
}
Exemple #3
0
func (p *replayCmds) Run() {
	c := data.NewCmdSetData()

	for _, cmdset := range p.cmdsets {
		cmds := c.GetCmdSet(cmdset)

		if len(cmds) == 0 {
			fmt.Printf("Command set %s not found.\n\n", cmdset)
		}

		for _, cmd := range cmds {
			p.cli.CliCommand(strings.Split(cmd, " ")...)
		}
	}
}
Exemple #4
0
func (r *recordCmd) Record(cmdsetName string) {
	var cmd string
	var err error
	d := data.NewCmdSetData()

	r.name = strings.TrimSpace(cmdsetName)

	if d.IsCmdExist(r.name) {
		fmt.Printf("\nThe name %s already exists, please use another ...\n\n", r.name)
		return
	}

	fmt.Printf(`Please start entering CF commands
For example: 'cf api http://api.10.244.0.34.xip.io --skip-ssl-validation'

type 'stop' to stop recording and save
type 'quit' to quit recording without saving

`)

	for {
		fmt.Printf("\n(recording) >> ")
		in := bufio.NewReader(os.Stdin)
		cmd, err = in.ReadString('\n')
		if err != nil {
			fmt.Println("Error: ", err)
			os.Exit(1)
		}

		if strings.TrimSpace(cmd) == "quit" {
			return
		}

		if strings.TrimSpace(cmd) == "stop" {
			break
		}

		if validCfCmd(cmd) {
			cmd = strings.TrimSpace(cmd)[3:]
			r.cmdset = append(r.cmdset, cmd)
			r.cli.CliCommand(strings.Split(cmd, " ")...)
		} else {
			fmt.Printf("Invalid CF command\n\n")
		}
	}

	d.SaveCmdSet(r.name, r.cmdset)
}
Exemple #5
0
func (r *recordCmd) ClearCmdSets() {
	d := data.NewCmdSetData()
	d.ClearCmdSets()
}
Exemple #6
0
func (r *recordCmd) DeleteCmdSet(cmdset string) {
	d := data.NewCmdSetData()
	d.DeleteCmdSet(cmdset)
}