On this page
CLI argument parsing, subcommand routing, and launch orchestration for the claudewheel command-line interface.
#claudewheel.cli
#claudewheel.cli
CLI argument parsing, subcommand routing, and launch orchestration.
#_do_uninstall
def _do_uninstall(version: str) -> intDelete an installed Claude Code version binary.
Refuses to delete the version the claude symlink currently points to, since that would break the default claude command. Returns a process exit code.
#_do_reset_options
def _do_reset_options() -> intDelete OPTIONS_FILE so it regenerates from defaults on next run.
Does NOT instantiate ConfigManager -- the next normal run will recreate options.json via _ensure_dir. Idempotent: missing file is not an error.
#_do_show
def _do_show(cfg: object) -> intPrint a git-status-like summary of last_config, segments, theme, and recent dirs.
#_write_tier_stub
def _write_tier_stub(profile: str | None, config_dir: str | None) -> NoneWrite a rateLimitTier stub into .credentials.json if tokens.json has tier data.
This lets downstream tools (e.g. howmuchleft) read the tier from .credentials.json even when auth is via CLAUDE_CODE_OAUTH_TOKEN. Short-circuits if .credentials.json already has the same tier value. Best-effort: silently skips on any error.
#_do_launch_sequence
def _do_launch_sequence(cfg: object, selections: dict, extra_flags: list[str] | None=None, interactive: bool=True, metadata: dict[str, dict[str, dict]] | None=None) -> NoneRun health check, hooks, save state, resolve, and exec. Does not return on success.
#_handle_new_profile
def _handle_new_profile() -> intRun the create-profile flow as one continuous alt-screen session.
Mirrors the TUI path: wizard form, auth forms, and summary page all render borrowed in a single alt-screen raw session on a CLI-owned terminal. After the session ends, the summary and auth outcome are printed to stdout as a persistent record.
#_handle_rename_profile
def _handle_rename_profile(old: str, new: str) -> intRename a profile: validate inputs, then delegate to core rename logic.
#_handle_check_tokens
def _handle_check_tokens() -> intValidate stored tokens for all discovered profiles against the Anthropic API.
#_handle_fix_auth
def _handle_fix_auth(name: str) -> intRemove session credentials that shadow a long-lived token.
#_check_resume_session
def _check_resume_session(session_id: str, directory: str) -> NoneIntercept --resume to detect and offer to fix directory renames.
When a session exists under an old encoded path (because the project directory was renamed), this function detects the mismatch and offers to move all sessions to the new path via run_mv.
Returns normally when no interception is needed (session found under current directory, or sessions successfully moved). Calls sys.exit(1) when the session cannot be resumed from here.
#_check_cont_session
def _check_cont_session(directory: str) -> NoneIntercept --cont to detect and offer to fix directory renames.
When the current directory has no sessions but an orphaned project directory exists under the same parent (original cwd no longer on disk), this function offers to move those sessions to the current directory via run_mv.
#_inject_launch
def _inject_launch(argv: list[str]) -> list[str]Return argv with the "launch" subcommand injected when appropriate.
argv includes argv[0] (the program name). When no subcommand is given, or the leading token is neither a known subcommand nor an app-level flag, the "launch" subcommand is injected so the interactive TUI starts. App-level flags (see _APP_LEVEL_FLAGS) and known subcommands are left untouched.
#_build_app
def _build_app() -> AppBuild the strictcli App with all subcommands registered.
#main
def main() -> NoneCLI entry point that parses arguments and dispatches to subcommands or the TUI.