Esempio n. 1
0
func createCommand(args []string, options cmds.Options) (cmds.Command, error) {
	if len(args) < 2 {
		return nil, errors.New("No bmp command specified")
	}

	var command cmds.Command

	cmdName := args[1]
	switch cmdName {
	case "bms":
		command = cmds.NewBmsCommand(options)
		break

	case "create-baremetals":
		command = cmds.NewCreateBaremetalsCommand(options)
		break

	case "login":
		command = cmds.NewLoginCommand(options)
		break

	case "sl-package-options":
		command = cmds.NewSlPackageOptionsCommand(options)
		break

	case "sl-packages":
		command = cmds.NewSlPackagesCommand(options)
		break

	case "status":
		command = cmds.NewStatusCommand(options)
		break

	case "stemcells":
		command = cmds.NewStemcellsCommand(options)
		break

	case "target":
		command = cmds.NewTargetCommand(options)
		break

	case "task":
		command = cmds.NewTaskCommand(options)
		break

	case "tasks":
		command = cmds.NewTasksCommand(options)
		break

	case "update-state":
		command = cmds.NewUpdateStateCommand(options)
		break

	default:
		return nil, errors.New(fmt.Sprintf("Unknown bmp command: %s", cmdName))
	}

	return command, nil
}
var _ = Describe("bms command", func() {

	var (
		args    []string
		options cmds.Options
		cmd     cmds.Command
	)

	BeforeEach(func() {
		args = []string{"bmp", "bms"}
		options = cmds.Options{
			Verbose: false,
		}

		cmd = cmds.NewBmsCommand(options)
	})

	Describe("NewBmsCommand", func() {
		It("create new BmsCommand", func() {
			Expect(cmd).ToNot(BeNil())

			cmd2 := cmds.NewBmsCommand(options)
			Expect(cmd2).ToNot(BeNil())
			Expect(cmd2).To(Equal(cmd))
		})
	})

	Describe("#Name", func() {
		It("returns the name of a BmsCommand", func() {
			Expect(cmd.Name()).To(Equal("bms"))