Skip to content
This repository was archived by the owner on Sep 20, 2026. It is now read-only.

refactor!: replace REPL with one-shot execution - #46

Draft
tisonkun wants to merge 3 commits into
mainfrom
codex/rewrite-oneshot-cli
Draft

tisonkun wants to merge 3 commits into
mainfrom
codex/rewrite-oneshot-cli

Conversation

@tisonkun

@tisonkun tisonkun commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • remove the interactive REPL and require an explicit CLI subcommand
  • preserve the familiar scopeql run <STATEMENT> positional input and -f/--file <FILE> script input
  • read redirected stdin when neither statement text nor a file is provided
  • keep stdin selection implicit instead of adding --command or -f - aliases
  • best-effort cancel the active server-side statement when scopeql run receives Ctrl+C
  • delete REPL-only terminal code and remove the reedline and indicatif dependency trees
  • document the new one-shot workflow and breaking changes

Motivation

ScopeQL statements are submitted independently and the current REPL does not provide server-side session semantics. Maintaining terminal editing, history, highlighting, slash commands, and signal workarounds therefore adds a large stateful surface without changing execution semantics.

The revised run command keeps the existing inline statement and explicit file interfaces while adding a shell-native path for generated or multiline input. Redirected stdin avoids additional flags and lets the shell handle files, pipelines, and heredocs directly.

Dropping the local execution future does not stop a statement already accepted by ScopeDB. The one-shot path therefore retains the existing statement cancellation protocol and sends POST /v1/statements/{id}/cancel on interruption.

CLI shape

scopeql run "SHOW DATABASES;"
scopeql run -f queries.scopeql
scopeql run < queries.scopeql
scopeql run <<"SCOPEQL"
SHOW DATABASES;
SHOW SCHEMAS;
SCOPEQL

When stdin is a terminal, scopeql run without input fails immediately with a usage-oriented error. Running bare scopeql displays command help instead of opening a REPL. -f - has no special stdin behavior.

While a statement is active, the first Ctrl+C asks ScopeDB to cancel that statement, waits up to five seconds, skips all remaining statements, and exits with status 130. A second Ctrl+C stops waiting immediately. Cancellation failures and timeouts report the statement ID because server-side execution may still be running.

Breaking changes

  • remove the REPL and all slash commands
  • make bare scopeql display help instead of opening an interactive session
  • stop prompting for first-connection setup from a bare invocation; scopeql connection add remains explicit

Validation

  • cargo x lint
  • cargo x check
  • cargo x test --no-capture (41 tests passed)
  • generated scopeql run --help smoke check
  • real SIGINT smoke test against a local mock server, verifying the cancel endpoint, cancellation result, and exit status 130

Open question

This draft deliberately keeps the existing config.toml discovery and --config-file behavior. Automatically discovering a project-local scopeql.toml deserves a separate decision because it changes credential placement and trust semantics.

@tisonkun

Copy link
Copy Markdown
Contributor Author

fyi @andylokandy @leiysky

This branch has not been deployed

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant