fix(cli): accept -l/--ledger on query/insert/upsert/update#1377
Open
bplatz wants to merge 1 commit into
Open
Conversation
The data commands only took the ledger as a positional argument, so the documented `fluree query --ledger <db> '<SPARQL>'` form errored with 'unexpected argument --ledger'. The metadata commands (history, branch, graph, show, drop) already used a --ledger flag, making the CLI inconsistent. Add -l/--ledger to query, insert, upsert, and update as an explicit alternative to the positional ledger. A new shared resolve_inputs wraps resolve_positional_args: when --ledger is given it takes precedence and bypasses the looks_like_query heuristic (positionals carry only inline data/query or a file path); otherwise the positional behavior is unchanged. Both forms now work. Document the flag in the CLI reference tables and add integration coverage. Closes #1368
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.
Summary
The data commands (
query,insert,upsert,update) only accepted the ledger as a positional argument, so the documented formfluree query --ledger knowledge-base:main '<SPARQL>'errored with
unexpected argument '--ledger' found. Meanwhile the metadata commands (history,branch,graph,show,drop) already used a--ledgerflag — an inconsistency reported in #1368.Changes
-l/--ledgertoquery,insert,upsert, andupdateas an explicit alternative to the positional ledger argument.resolve_inputs(ledger_flag, args)wraps the existingresolve_positional_args: when--ledgeris given it takes precedence and bypasses thelooks_like_queryheuristic (positionals carry only inline data/query or a file path; a stray second positional is rejected with a clear usage error). When the flag is absent, positional behavior is unchanged.docs/cli/{query,insert,upsert,update}.mdoption tables.Tests
query_and_insert_accept_ledger_flagandquery_ledger_flag_rejects_extra_positionalinfluree-db-cli/tests/integration.rs.cargo fmt+clippy --all-features --all-targets -D warningsclean.Closes #1368