Refactor CLI code to separate user input from execution
Opened this issue · 1 comments
ryardley commented
How do we test our cli?
We need to be able to test our cli by removing the UI from the actually processes.
We should tidy up and refactor the CLI code to separate layers:
- user input.
- validation.
- execution.
Why should we do this?
- Being able to mock the input layer will mean we can easily test the cli validation layer and assert against the results.
- We can replace the top layer with passed in values removing all interactivity.
- We can assume that if our validation is good enough that execution will likely succeed.
- We can test the underlying functions.
- Consistency / Readability
ryardley commented
I think having a separate validation layer is probably overkill. Most validation is going to be ensuring we don't have null strings and that addresses are actually addresses. We can use good types to pass to the library layer.