Esempio n. 1
0
func RunCommand(cmd commands.Command, ctxt *cli.Context, reqFactory *testreq.FakeReqFactory) {
	defer func() {
		errMsg := recover()

		if errMsg != nil && errMsg != testterm.FailedWasCalled {
			panic(errMsg)
		}
	}()

	CommandDidPassRequirements = false

	requirements, err := cmd.GetRequirements(reqFactory, ctxt)
	if err != nil {
		return
	}

	for _, requirement := range requirements {
		success := requirement.Execute()
		if !success {
			return
		}
	}

	CommandDidPassRequirements = true
	cmd.Run(ctxt)

	return
}
Esempio n. 2
0
func RunCommand(cmd commands.Command, ctxt *cli.Context, reqFactory *FakeReqFactory) {
	CommandDidPassRequirements = false

	reqs, err := cmd.GetRequirements(reqFactory, ctxt)
	if err != nil {
		return
	}

	for _, req := range reqs {
		err = req.Execute()
		if err != nil {
			return
		}
	}

	cmd.Run(ctxt)
	CommandDidPassRequirements = true

	return
}