abiosoft / caddy-docker

Docker container for Caddy
https://hub.docker.com/r/abiosoft/caddy/
MIT License
768 stars 315 forks source link

Inconsistent parsing of command line flags #107

Closed ithinkihaveacat closed 6 years ago

ithinkihaveacat commented 6 years ago

caddy parses command line options inconsistently: in some cases both -option value and -option=value is accepted, but in others only the first is accepted.

Both forms accepted for -type:

$ caddy -type http -validate
Caddyfile is valid
$ caddy -type=http -validate
Caddyfile is valid

Only one for accepted for -http2:

$ caddy -http2 false -validate
2018/04/26 10:32:45 args:2 - Error during parsing: Unknown directive 'false'
$ caddy -http2=false -validate
Caddyfile is valid

The documentation does not suggest there would be any difference in the way these options are parsed:

  -http2
        Use HTTP/2 (default true)
...
  -type string
        Type of server to run (default "http")
abiosoft commented 6 years ago

It is not inconsistent, it is how Go parses command line. Booleans are different.

To set boolean you need = i.e. -http2=false.

ithinkihaveacat commented 6 years ago

Ah, I see. In that case, can the documentation be changed to make this clear? I suspect many users are not familiar with the details of go's command-line parsing behavior (or even that caddy is written in go).

Perhaps:

-http2=true|false
abiosoft commented 6 years ago

Yeah you're right end users may not know. Noted.