コード例 #1
0
ファイル: bmp.go プロジェクト: gitter-badger/bosh-bmp-cli
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
}
コード例 #2
0
var _ = Describe("sl-packages command", func() {

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

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

		cmd = cmds.NewSlPackagesCommand(options)
	})

	Describe("NewSlPackagesCommand", func() {
		It("create new SlPackagesCommand", func() {
			Expect(cmd).ToNot(BeNil())

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

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