Skip to content

Add --provider and --model CLI flags for one-shot overrides #5

Description

@Osso

Summary

Let users pick the provider and/or model for a single launch from the
command line, without editing config or opening the TUI's
`/config` / `/provider` / `/model` flow.

Useful for shell aliases, scripted launches, and ad-hoc model swaps:

```
ask --provider codex --model gpt-5
ask --provider claude
alias askc='ask --provider claude --model claude-sonnet-4-6'
```

Happy to PR; carrying it locally already.

Behavior sketch

  • `--provider ` / `--provider=` — set the provider for this run only,
    applied after `saveConfig(cfg)` so it never persists. Unknown ids exit
    with status 2 and an error listing the registered ids; resolve via a strict
    registry lookup so a typo does not silently fall back to the first provider.
  • `--model ` / `--model=` — set `first.providerModel` after
    `newTab` returns, so the override beats the provider's saved settings
    without modifying them. No validation: the in-TUI model picker already
    supports custom strings, so anything the picker would accept is legal here.
  • Bare `--provider` / `--model` (no value) and empty `--provider=` /
    `--model=` are validation errors so a typo doesn't swallow the next
    positional arg.
  • Parse the new flags before the existing `resume` / `--help` / `_hook`
    dispatch so they don't trip an unknown-option check.
  • `printHelp` documents both flags under an `Options:` section.

Tests worth adding

  • known provider id → applied
  • unknown provider id → exit 2 with helpful error
  • bare `--provider` (no value) → validation error
  • `--model foo` → `first.providerModel == "foo"`
  • `--provider claude --model bar` → both applied

Notes

This pairs naturally with #4 (`ask resume ` ignoring `LastProvider`):
once both land, a user can do `ask --provider codex resume ` to
explicitly force a cross-provider resume, and the no-flag case picks up
`LastProvider`.

Activity

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

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