Skip to content
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

Feature: Strict mode / validation #506

Closed
d4h0 opened this issue Jan 18, 2021 · 10 comments
Closed

Feature: Strict mode / validation #506

d4h0 opened this issue Jan 18, 2021 · 10 comments
Assignees
Milestone

Comments

@d4h0
Copy link

d4h0 commented Jan 18, 2021

Feature Description

It would be nice, if there was an option for a strict mode that validates Makefile.toml files.

For example, I had the following task:

[tasks.start-dev-server]
commad = "${NODE_BIN}/browser-sync"
args = ["start", "--server", "build/dev", "--no-open", "--watch"

...and was wondering why my live-reload server didn't work.

Turned out, I missed an "n" in "command".

Describe The Solution You'd Like

Would it be possible to recognize cases like these, and fail or show a warning?

Maybe the strsim crate would be useful for nice error messages ("Unknown option 'commad', did you mean 'command'?"). But that just would be a 'nice to have', nothing essential.

Thanks, for creating cargo make!

@sagiegurari
Copy link
Owner

that is super interesting idea.
I will check what can be done (I will check serde docs).
by the way, PRs are always welcome as well :)

@d4h0
Copy link
Author

d4h0 commented Jan 19, 2021

Sounds good :)

Serde has the deny_unknown_fields attribute (#[serde(deny_unknown_fields)]), which might be useful. But I'm not sure if that would work with the feature set that cargo make has.

@sagiegurari
Copy link
Owner

thanks. the issue i see with that attribute is that its not something i can turn on/off when running deserialize.
its impacting always.

@sagiegurari
Copy link
Owner

@d4h0 this one feels like a good direction to me: https://github.com/dtolnay/serde-ignored

@d4h0
Copy link
Author

d4h0 commented Jan 19, 2021

I didn't know serde-ignored – thanks! Yes, that looks perfect.

@sagiegurari
Copy link
Owner

@d4h0 this is now implemented in the dev branch 0.32.11
give it a shot and tell me what you think.
it will print a warning for any unknown key found including which file it was found in.

@d4h0
Copy link
Author

d4h0 commented Jan 23, 2021

@sagiegurari: Works fantastic – thank you so much!

@sagiegurari
Copy link
Owner

thanks for the feedback.

@sagiegurari
Copy link
Owner

officially released.

@d4h0
Copy link
Author

d4h0 commented Jan 26, 2021

@sagiegurari: Awesome, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants