On this page
Command-line interface entry point for claudestream, providing send, listen, and agent commands for interacting with Claude Code.
#claudestream._cli
#claudestream._cli
Command-line interface entry point for claudestream, providing send, listen, and agent commands for interacting with Claude Code.
#_get_version
def _get_version() -> strRead version from pyproject.toml (editable installs) or fall back to package metadata.
#_opt
def _opt(value, fallback)Resolve an optional flag's absence to the fallback its help declares.
strictcli's mutating-default ban forbids default= on any flag of a mutating command: a value the framework picks is a value the framework writes. claudestream's session commands are all mutating, so their behavioral switches (--footer, --color, --raw, --stdin, --skip-permissions, --json-output) declare presence="optional" and name their fallback in their own help text. This is the one place where absence becomes that fallback, so nothing downstream ever sees a None it would silently read as false.
#_resolve_prompt
def _resolve_prompt(prompt: str | None, stdin: bool, color: Colorizer) -> str | intResolve prompt from argument or stdin. Returns the prompt string, or 1 on error.
prompt is None when the positional argument was not supplied at all -- the optional presence declaration delivers absence as absence, so an explicitly supplied empty string is a supplied prompt, not an absent one.
#_build_config
def _build_config(model: str, profile: str, cwd: str | None=None, skip_permissions: bool=False, system_prompt: str | None=None, resume: str | None=None, from_pr: str | None=None) -> SessionConfigBuild a SessionConfig from common CLI flags.
Every str | None parameter here is fed by a flag declaring presence="optional", so absence arrives as None and is passed straight through -- no empty-string sentinel is constructed or tested.
#_run_with_session
def _run_with_session(config: SessionConfig, handler: Any, color: Colorizer) -> int | NoneRun handler(session) inside a SyncSession context with standard error handling.
#_stream_events
def _stream_events(session: SyncSession, prompt: str, footer: bool, color: Colorizer) -> NoneShared streaming event loop used by cmd_stream and cmd_agent_run.
#cmd_send
def cmd_send(ctx, prompt: str | None=None, model: str='', profile: str='', cwd: str | None=None, raw: bool | None=None, json_output: bool | None=None, skip_permissions: bool | None=None, footer: bool | None=None, system_prompt: str | None=None, stdin: bool | None=None, color: bool | None=None, resume: str | None=None, from_pr: str | None=None) -> int | None#cmd_stream
def cmd_stream(ctx, prompt: str | None=None, model: str='', profile: str='', cwd: str | None=None, skip_permissions: bool | None=None, footer: bool | None=None, system_prompt: str | None=None, stdin: bool | None=None, color: bool | None=None, resume: str | None=None, from_pr: str | None=None) -> int | None#cmd_events
def cmd_events(ctx, prompt: str | None=None, model: str='', profile: str='', cwd: str | None=None, skip_permissions: bool | None=None, footer: bool | None=None, system_prompt: str | None=None, stdin: bool | None=None, color: bool | None=None, resume: str | None=None, from_pr: str | None=None) -> int | None#cmd_repl
def cmd_repl(ctx, model: str, profile: str, cwd: str | None=None, skip_permissions: bool | None=None, footer: bool | None=None, system_prompt: str | None=None, color: bool | None=None, resume: str | None=None, from_pr: str | None=None) -> None#cmd_agent_run
def cmd_agent_run(ctx, definition: str, prompt: str, var: list[str], profile: str, model: str | None=None, cwd: str | None=None, footer: bool | None=None, color: bool | None=None) -> int | None#cmd_agent_list
def cmd_agent_list(ctx, cwd: str | None=None) -> int | None#cmd_agent_info
def cmd_agent_info(ctx, name: str) -> int | None#cmd_agent_validate
def cmd_agent_validate(ctx, name: str) -> int | None#cmd_ask
def cmd_ask(ctx, prompt: str | None=None, model: str='', profile: str='', cwd: str | None=None, skip_permissions: bool | None=None, system_prompt: str | None=None, stdin: bool | None=None, json_output: bool | None=None, color: bool | None=None, from_pr: str | None=None) -> int | None#cmd_doctor
def cmd_doctor(ctx, profile: str | None=None) -> int | None#cmd_config
def cmd_config(ctx, profile: str | None=None) -> int | None#EventPrinter
Stateful event printer that deduplicates AssistantText against StreamDelta.
#print_event
def print_event(self, event: Event) -> NonePretty-print an event to stdout, deduplicating AssistantText.
#_print_json
def _print_json(event: Event) -> NonePrint an event as a JSON line.
#main
def main() -> None