canonical / charmcraft

Collaborate, build and publish charmed operators for Kubernetes, Linux and Windows.
Apache License 2.0
66 stars 71 forks source link

Add `charmcraft fmt` command #913

Open sed-i opened 2 years ago

sed-i commented 2 years ago

It could be handy if charmcraft had an fmt command to apply a set of opinionated formatting choices. For example:

facundobatista commented 2 years ago

Hello! This would be format, right?

In your idea this will improve the metadata.yaml layout, without touching any semantic content, right? Any other files? We should define the reach of this format and gain consensus on what is a good idea to change and what is not. Maybe a forum post?

What do you think? Thanks!

sed-i commented 2 years ago

Correct, the idea is to be able to offer "aesthetic consistency" across charms, without making any semantic/functional changes. Similar to go fmt, cargo fmt, terraform fmt, ...

If you generally agree on the premise then a post might be a good idea.

jnsgruk commented 2 years ago

This is quite interesting. One possible extension here is suggesting style on interface names and config items (I.e. _ vs - as separators etc)

facundobatista commented 1 year ago

I went ahead and created a post in the forum to collect more changes. Once that stabilizes we could formalize this.

Regarding the command, I would go with format, as we're trying to not use abbreviations. Also, I would add a --diff option to it, to not write the files back, just output a diff for each file on stdout.