rust icon indicating copy to clipboard operation
rust copied to clipboard

exercise util: use templates instead of manually modifying files

Open coriolinus opened this issue 7 years ago • 2 comments

Currently many operations in this utility operate at the file level, directly appending strings and bytes. We'll get better results with higher-level abstractions: never directly appending to Config.toml, for example, but using a toml-parsing crate instead. Likewise, writing the tests file will be much easier using a template system like handlebars. Note that this mention of handlebars isn't a requirement to use that particular crate, just an example of a plausible templating engine.

It is not necessary to implement this before #679 or #686, but those issues will probably be easier to fix after the fix for this has been implemented.

coriolinus avatar Oct 28 '18 11:10 coriolinus

If by Config.toml you mean Cargo.toml, then it is already parsed with the toml crate and there is no appending: the content of the file is parsed, modified and then the new content fully overrides the old one. What should be added to this behavior in the context of this issue?

ZapAnton avatar Oct 28 '18 13:10 ZapAnton

See the changes here. There are some other changes in that diff, mostly due to some necessary macro refactoring, but that file has the most important ones.

coriolinus avatar Oct 28 '18 14:10 coriolinus

exercise util has been deleted since, see this thread for more context.

senekor avatar Sep 11 '23 21:09 senekor