-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
If you call caddy fmt
with the path to more than one file, it only formats the first file.
For example:
$ caddy fmt 1.Caddyfile 2.Caddyfile --overwrite
then 1.Caddyfile
will be reformatted, but 2.Caddyfile
will be silently ignored.
If I look in the docs, I can see that caddy fmt
only supports passing a single path – but it took me a while to realise that! This is different from other formatting tools I've used (e.g. black
, terraform fmt
) where you can pass multiple files and format them all together.
I think it would be less confusing if caddy fmt
either:
- Formatted every
<path>
passed to it, or - Threw an error if you tried to pass more than one
<path>
Context
I'd written a command to find all the Caddyfiles in my repo and format them:
$ find . -name Caddyfile | xargs --verbose caddy fmt
caddy fmt 1/Caddyfile 2/Caddyfile
and I was getting inconsistent results between different machines – it took me a while to notice that find
was returning results in an inconsistent order, and caddy
was only formatting the first in the list.
I don't really mind what caddy
does, but the current behaviour caused a lot of confusion.
Version
$ caddy --version
v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=