Пример #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("sl-package-options command", func() {

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

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

		cmd = cmds.NewSlPackageOptionsCommand(options)
	})

	Describe("NewSlPackageOptionsCommand", func() {
		It("create new SlPackageOptionsCommand", func() {
			Expect(cmd).ToNot(BeNil())

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

	Describe("#Name", func() {
		It("returns the name of a SlPackageOptionsCommand", func() {
			Expect(cmd.Name()).To(Equal("sl-package-options"))