Skip to content

fix(cli): accept -l/--ledger on query/insert/upsert/update#1377

Open
bplatz wants to merge 1 commit into
mainfrom
fix/cli-ledger-flag-1368
Open

fix(cli): accept -l/--ledger on query/insert/upsert/update#1377
bplatz wants to merge 1 commit into
mainfrom
fix/cli-ledger-flag-1368

Conversation

@bplatz

@bplatz bplatz commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

The data commands (query, insert, upsert, update) only accepted the ledger as a positional argument, so the documented form

fluree query --ledger knowledge-base:main '<SPARQL>'

errored with unexpected argument '--ledger' found. Meanwhile the metadata commands (history, branch, graph, show, drop) already used a --ledger flag — an inconsistency reported in #1368.

Changes

  • Add -l/--ledger to query, insert, upsert, and update as an explicit alternative to the positional ledger argument.
  • New shared resolve_inputs(ledger_flag, args) wraps the existing 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; a stray second positional is rejected with a clear usage error). When the flag is absent, positional behavior is unchanged.
  • Both forms now work:
    fluree query knowledge-base:main 'SELECT …'            # positional (still works)
    fluree query --ledger knowledge-base:main 'SELECT …'   # flag (now works)
  • Document the flag in the docs/cli/{query,insert,upsert,update}.md option tables.

Tests

  • query_and_insert_accept_ledger_flag and query_ledger_flag_rejects_extra_positional in fluree-db-cli/tests/integration.rs.
  • Full CLI integration suite passes (95); cargo fmt + clippy --all-features --all-targets -D warnings clean.

Closes #1368

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation Error: fluree query examples use unsupported --ledger option

1 participant