feat: adopt docopt-config 0.3.0 - #8
Merged
Merged
Conversation
- config floats and large ints now survive (Float64/Int64 arms in Cli.option_string), so margin: 20.5 works instead of being dropped - simplify Cli.option_flag: docopt-config now coerces env var values itself (MARKTERM_HYPHENATE=1 is a real boolean, MARKPDF_FONT=a.ttf ,b.ttf comma-splits into a list) - add --print-config to all three CLIs: dumps the fully-resolved configuration as YAML that can be saved and used as a config file - usage errors now print the message and usage to stderr and exit 1 (0.2.0 exited 0), and unparseable config files warn on stderr instead of failing silently - README: document env var coercion, --print-config and the new warning behavior
All three CLIs accept --config <path> (or --config=<path>) to read options from a specific YAML file instead of the per-tool XDG default. An explicitly given file must exist; the flag itself only comes from the command line, and tokens after -- are never taken as --config.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adopts docopt-config v0.3.0 in all three CLIs (
markterm,markmark,markpdf), which shipped several improvements since the v0.2.0 integration.What we gain
--print-config(all three CLIs): dumps the fully-resolved configuration — CLI arguments, environment variables, config file and docopt defaults merged — as YAML that can be saved and used as a config file as is:markterm/markmarkstill require their file argument, so use e.g.markterm --print-config - < document.md.MARKTERM_HYPHENATE=1is now a real boolean, and repeatable options accept comma-separated lists (MARKPDF_FONT=a.ttf,b.ttf).Adaptation required by this PR
v0.3.0 preserves config-file floats and large integers as
Float64/Int64instead of stringifying them.Cli.option_stringnow handles all numeric types, somargin: 20.5keeps working instead of being dropped.Cli.option_flagshrank tovalue == truesince the library now coerces env values itself.Verification
shards build: all four binaries buildcrystal spec: 231 examples, 0 failuresameba: 0 failures--helpoutput--print-configroundtrip (dump → save as config.yml → same effective configuration)