Conversation
- Strip internal `::implicit-true-keys` and `::keys-order` from `parse-opts` result metadata. - Track key parse order in `parse-opts*` meta; `coerce-opts` iterates by it so coerce errors fire in parse order, not map hash order. - Document that `:exec-args` values bypass coercion. - Tests: meta-not-leaked, coerce-error-order for >8 keys, pinning tests for `:bool` and coll-wrapped `:boolean`.
Decouples parse / coerce / validate / defaults so callers can interleave external config (e.g. config files) into the pipeline: parse-opts* -> external merge -> apply-defaults -> coerce-opts -> validate-opts - `parse-opts*` is now public: parses CLI args to a raw map with no coercion, no defaults, no validation. Useful for peek-style parsing and for callers that need to merge config from elsewhere before coercion. - `apply-defaults` fills missing keys from spec `:default` entries (via `:exec-args`). Preserves metadata of input. - `coerce-opts` now reads `::implicit-true-keys` and `::keys-order` from input metadata when not explicitly passed in opts, so callers don't need to thread them manually. Tests added: parse-opts*, apply-defaults, full squint-style pipeline.
Previously the only way for a caller to detect 'user supplied --foo without a value, coerce rejected the implicit true' was to pattern- match on :value being the string "true" - fragile because the same string from explicit '--foo true' would also match, and "true" was a parser-internal stringification. Surface :implicit-true true in error data when the failure originates from an implicit-true coercion. throw-coerce already had the info as an arg; just put it in ex-data and propagate through the catch in coerce-opts.
# Conflicts: # CHANGELOG.md # test/babashka/cli_test.cljc
setup-clojure 13.x hits GH API to resolve 'latest'; with the implicit token it currently fails 'Bad credentials' on Windows runners. Pin to a specific bb version (avoids the API lookup) and pass the token explicitly.
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.
No description provided.