Skip to content

cli: let infoctl query take SQL that starts with a comment #96

Open

Description

@codecapo

infoctl query takes the SQL as one quoted argument, and parse_query treats every argument that starts with -- as an option (crates/cli/src/lib.rs:107 at b3017eb on PR #46's branch). A statement that opens with a SQL line comment, as saved queries and editor snippets often do, is therefore refused before it is parsed:

$ infoctl query "-- daily totals
select * from ready.daily_revenue"
infoctl query: unknown option -- daily totals
select * from ready.daily_revenue

and the command exits 2. There is also no way to pass such a statement, because the parser has no end-of-options marker. Take the convention other command lines use: a bare -- ends option parsing and everything after it is the SQL. On top of that, an argument that starts with -- but contains whitespace cannot be an option, so it can be taken as SQL without the marker; a typo such as --verbose has no whitespace and stays a usage error.

Crate: crates/cli (src/lib.rs: parse_query and USAGE; tests/query.rs or the unit tests in src/lib.rs)

Done when

  • infoctl query "-- daily totals\nselect 1", one argument holding a newline, runs the query and exits 0.
  • infoctl query --format csv -- "select 1" runs the query with CSV output, and infoctl query -- --format treats --format as the SQL and fails as SQL with exit 1, not as a usage error with exit 2.
  • infoctl query --verbose "select 1" still exits 2 with unknown option --verbose, and --warehouse and --format keep working before the --.
  • The QUERY: block of USAGE shows the -- marker.
  • Each case above is a test, and each test fails when the parser is put back to treating every -- argument as an option.

Points: 1

Depends on: #15 (the parser PR #46 adds)
Blocks: nothing

Source: review of PR #46, 2026-11-09.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions