Coverage for src / cli.py: 78%

18 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-02-13 20:29 +0800

1"""CLI 入口.""" 

2 

3import typer 

4from rich.console import Console 

5 

6app = typer.Typer(help="GEO-SEO Optimizer CLI") 

7console = Console() 

8 

9 

10@app.command() 

11def keywords( 

12 action: str = typer.Argument(...), 

13 query: str = typer.Argument(...), 

14 output: str = typer.Option(None, "--output", "-o"), 

15) -> None: 

16 """关键词研究命令.""" 

17 console.print(f"[green]关键词研究: {query}[/green]") 

18 

19 

20@app.command() 

21def content( 

22 action: str = typer.Argument(...), 

23 source: str = typer.Argument(...), 

24 platform: str = typer.Option(None, "--platform", "-p"), 

25 seo: bool = typer.Option(True, "--seo/--no-seo"), 

26 geo: bool = typer.Option(True, "--geo/--no-geo"), 

27) -> None: 

28 """内容生成命令.""" 

29 console.print(f"[green]内容生成: {source}[/green]") 

30 

31 

32@app.command() 

33def adapt( 

34 content_file: str = typer.Argument(...), 

35 platform: str = typer.Option(..., "--platform", "-p"), 

36 output: str = typer.Option(None, "--output", "-o"), 

37) -> None: 

38 """平台适配命令.""" 

39 console.print(f"[green]适配到 {platform}[/green]") 

40 

41 

42@app.command() 

43def analytics( 

44 action: str = typer.Argument(...), 

45 target: str = typer.Argument(None), 

46 days: int = typer.Option(30, "--days", "-d"), 

47) -> None: 

48 """分析命令.""" 

49 console.print(f"[green]分析: {action}[/green]") 

50 

51 

52def main() -> None: 

53 app() 

54 

55 

56if __name__ == "__main__": 

57 main()