Coverage for src/clauth/cli.py: 90%

20 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-09-28 14:45 -0400

1# Copyright (c) 2025 Mahmood Khordoo 

2# 

3# This software is licensed under the MIT License. 

4# See the LICENSE file in the root directory for details. 

5 

6""" 

7CLAUTH Command Line Interface. 

8 

9This module provides the main CLI interface for CLAUTH, a tool that streamlines 

10AWS Bedrock setup for Claude Code. It handles AWS SSO authentication, model 

11discovery, environment configuration, and Claude Code CLI launching. 

12 

13Main Commands: 

14 init: Interactive setup wizard for AWS SSO and model selection 

15 list-models: Display available Bedrock inference profiles 

16 claude: Launch Claude Code CLI with proper environment 

17 config: Configuration management (show, set, reset, profiles) 

18""" 

19 

20import typer 

21import os 

22from typer.core import TyperGroup 

23from clauth.commands import ( 

24 model_app, 

25 delete, 

26 config_app, 

27 init_command, 

28) 

29from clauth.launcher import launch_claude_cli 

30from rich.console import Console 

31 

32 

33 

34class OrderedGroup(TyperGroup): 

35 def list_commands(self, ctx): 

36 return ["init", "model", "config", "delete"] 

37 

38app = typer.Typer(cls=OrderedGroup, no_args_is_help=False, invoke_without_command=True) 

39env = os.environ.copy() 

40console = Console() 

41 

42 

43@app.callback() 

44def main(ctx: typer.Context): 

45 """ 

46 CLAUTH: A streamlined launcher for the Claude Code CLI with AWS Bedrock. 

47 """ 

48 if ctx.invoked_subcommand is None: 

49 launch_claude_cli() 

50 

51# Register commands from modules 

52app.command(name="init")(init_command) 

53app.add_typer(model_app, name="model") 

54app.add_typer(config_app, name="config") 

55app.command()(delete) 

56 

57 

58 

59if __name__ == "__main__": 

60 app()