gh-gei
gh-gei copied to clipboard
Move validations into the arg class
Currently we perform the arg validations inside the command handler class sometimes right inside the handle method or in its own dedicated method (or more than one method even).
The problems with this approach are:
- We do the validations after we create the handler which is not ideal. We shouldn't even create the handler if the validation fails.
- There is no uniform pattern for validations. Sometimes we do them in a single place or sometimes they are scattered in a handler class inside different methods which makes it harder to keep a track and make changes, also there is a possibility of missing some.
Todo
- [ ] Create a
Validatemethod inside each arg class (it can come from a base arg class and be overridden in the arg class) and put all arg validations in it. - [ ] Remove the validations from the command handler classes and call the
Validatemethod in the command class as part of theBuildHandlermethod. - [ ] Rethink about arg validations case by case specially for larger commands like
migrate-repoorgenerate-script. Like for example inbb2gh migrate-repocommand if we don't pass the--github-organd--github-repoour code is not going to work properly, so we need to reconsider all possible scenarios and write appropriate tests to cover them.