Skip to content

CLI should reject conflicting command/query/file combinations #68

@ndenev

Description

@ndenev

Summary

k8sql accepts conflicting CLI inputs and silently prioritizes one path over another in some cases. This can ignore user intent without warning.

Reproduced behavior

1) -q and -f together

k8sql -q "SELECT 1" -f /tmp/realfile.sql

Observed: executes -q query and ignores -f.

2) Global query flag with subcommand

k8sql -q "SELECT 1" daemon

Observed: starts daemon, query is ignored.

3) Position-dependent UX inconsistency

k8sql daemon -q "SELECT 1"

Observed: clap rejects -q as unexpected argument.

Equivalent conflicting intent is accepted/rejected depending on ordering.

Affected code

  • CLI definitions: src/cli/args.rs
  • Precedence in runtime dispatch: src/main.rs

Root cause

  • Args does not declare conflicts between:
    • command vs query
    • command vs file
    • query vs file
  • main then applies imperative precedence (command first, then batch; query before file).

Impact

  • Silent argument ignoring
  • Confusing UX
  • Script/automation mistakes are harder to detect

Proposed fix (recommended)

Use clap-level constraints so invalid combinations fail fast with clear messages:

  1. query conflicts with file and command
  2. file conflicts with query and command
  3. Optionally model batch args in an ArgGroup for clarity

Tests to add

Add parser tests for failures on:

  • k8sql -q "..." -f file.sql
  • k8sql -q "..." daemon
  • k8sql -f file.sql interactive

Ensure errors are stable and user-facing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions