Opts.env withDefault produces empty braces in usage
ivan-klass opened this issue · comments
Adding withDefault
to Opts.env
results in confusing empty braces being rendered in usage.
Example:
import cats.syntax.all.given
import com.monovore.decline.{CommandApp, Opts}
object EmptyBraces
extends CommandApp(
"test",
"test",
(
Opts.option[Int]("number", "Print N times", metavar = "N"),
Opts.env[String]("GREETING", "A greeting").withDefault("Hi"), // FIRST []
Opts.env[String]("BODY", "The content"), // NO DEFAULT - OK
Opts.env[String]("FOOTER", "Ending").withDefault("Best regards"), // SECOND []
Opts.option[String]("name", "Who to greet")
).mapN { case (n, greeting, body, footer, name) =>
println(s"$greeting $name\n$body\n$footer" * n)
}
)
Usage output:
Missing expected flag --number!
Missing expected environment variable (BODY)!
Missing expected flag --name!
Usage: test --number <N> [] [] --name <string>
test
Options and flags:
--help
Display this help text.
--number <N>
Print N times
--name <string>
Who to greet
Environment Variables:
GREETING=<string>
A greeting
BODY=<string>
The content
FOOTER=<string>
Ending
Note [] []
in Usage:
- according to my tests, It seems like every Opts.env(...).withDefault
produces an empty braces pair
Fascinating - thanks for the report! I'll take a look.
2.4.1
is out with the fix. Thanks again for the report!