-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: refactor validtors of cobra commond args #478
Comments
|
Hi @aFlyBird0, thanks for your enthusiastic contribution! I have read your PR already; sorry for the late reply. I'll reply directly to the issue instead of in the PR. We follow the standard go project layout, and according to those conventions, the cmd folder shouldn't contain a lot of code. If you think the code can be imported and used in other projects, then it should live in the In this case, I think the validator.go file is better to be put under Feel free to have a discussion here or in our WeChat user group or slack channel :) Thanks again @aFlyBird0 |
The validator is a kind of entry logic. So it is more suitable under |
Thank you both for your advice. @daniel-hutao @IronCore864 I have finished coding |
closed by #479 |
Description
To make validators more elegant:
Describe the Proposal
take
show
cmd for example:I will delete code like
if err:= validate...Show(args); err!=nil{log.Fatal(err)
in all commonds.New code will be like:
There is duplicate code like:
I will define some common validators to program easier and keep error messages consistent.
However, I'am not sure where to put code about validators interface, maybe
/cmd/devstream/validator/validator.go
? Or just in/cmd/devstream/validator.go
to hide pkg names. Can you give me some advice? @daniel-hutaoHas the Feature been Requested Before?
Describe the Alternatives You Have Considered
Additional Context
The text was updated successfully, but these errors were encountered: