Manage LLM providers.
(
subcommand: str | None = typer.Argument(
None, help="Subcommand: list, config, diagnostic, set, or provider name"
),
provider_name: str | None = typer.Argument(
None, help="Provider name (for set or switch commands)"
),
key: str | None = typer.Argument(None, help="Config key (for set command)"),
value: str | None = typer.Argument(None, help="Config value (for set command)"),
model: str | None = typer.Option(
None, "--model", help="Model name (for switch commands)"
),
config_file: str = typer.Option(
"server_config.json", help="Configuration file path"
),
server: str | None = typer.Option(None, help="Server to connect to"),
disable_filesystem: bool = typer.Option(False, help="Disable filesystem access"),
quiet: bool = typer.Option(False, "-q", "--quiet", help="Suppress most log output"),
verbose: bool = typer.Option(
False, "-v", "--verbose", help="Enable verbose logging"
),
log_level: str = typer.Option("WARNING", "--log-level", help="Set log level"),
theme: str = typer.Option("default", "--theme", help="UI theme"),
)
| 911 | # Provider command - FIXED to handle arguments properly |
| 912 | @app.command("provider", help="Manage LLM providers") |
| 913 | def provider_command( |
| 914 | subcommand: str | None = typer.Argument( |
| 915 | None, help="Subcommand: list, config, diagnostic, set, or provider name" |
| 916 | ), |
| 917 | provider_name: str | None = typer.Argument( |
| 918 | None, help="Provider name (for set or switch commands)" |
| 919 | ), |
| 920 | key: str | None = typer.Argument(None, help="Config key (for set command)"), |
| 921 | value: str | None = typer.Argument(None, help="Config value (for set command)"), |
| 922 | model: str | None = typer.Option( |
| 923 | None, "--model", help="Model name (for switch commands)" |
| 924 | ), |
| 925 | config_file: str = typer.Option( |
| 926 | "server_config.json", help="Configuration file path" |
| 927 | ), |
| 928 | server: str | None = typer.Option(None, help="Server to connect to"), |
| 929 | disable_filesystem: bool = typer.Option(False, help="Disable filesystem access"), |
| 930 | quiet: bool = typer.Option(False, "-q", "--quiet", help="Suppress most log output"), |
| 931 | verbose: bool = typer.Option( |
| 932 | False, "-v", "--verbose", help="Enable verbose logging" |
| 933 | ), |
| 934 | log_level: str = typer.Option("WARNING", "--log-level", help="Set log level"), |
| 935 | theme: str = typer.Option("default", "--theme", help="UI theme"), |
| 936 | ) -> None: |
| 937 | """Manage LLM providers.""" |
| 938 | # Configure logging and theme for this command |
| 939 | _setup_command_logging(quiet, verbose, log_level, theme) |
| 940 | |
| 941 | # Build arguments list for the provider action |
| 942 | args: list[str] = [] |
| 943 | |
| 944 | # Handle different command patterns |
| 945 | if subcommand is None: |
| 946 | # No arguments - show status |
| 947 | args = [] |
| 948 | elif subcommand in ["list", "config", "diagnostic", "custom"]: |
| 949 | # Command without provider name |
| 950 | args = [subcommand] |
| 951 | if provider_name and subcommand == "diagnostic": |
| 952 | # diagnostic can take a provider name |
| 953 | args.append(provider_name) |
| 954 | elif subcommand == "add": |
| 955 | # add command: add <name> <api_base> [models...] |
| 956 | if not provider_name or not key: |
| 957 | output.error( |
| 958 | "add command requires: provider add <name> <api_base> [model1 model2 ...]" |
| 959 | ) |
| 960 | raise typer.Exit(1) |
| 961 | args = [subcommand, provider_name, key] # key is used as api_base |
| 962 | if value: |
| 963 | args.append(value) # value is the first model |
| 964 | elif subcommand == "remove": |
| 965 | # remove command: remove <name> |
| 966 | if not provider_name: |
| 967 | output.error("remove command requires: provider remove <name>") |
| 968 | raise typer.Exit(1) |
| 969 | args = [subcommand, provider_name] |
| 970 | elif subcommand == "set": |
nothing calls this directly
no test coverage detected