Parse command-line arguments
()
| 44 | |
| 45 | |
| 46 | def parse_args(): |
| 47 | """Parse command-line arguments""" |
| 48 | parser = argparse.ArgumentParser( |
| 49 | description="Image2PPT CLI - Convert images to editable PPT", |
| 50 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 51 | epilog=""" |
| 52 | Examples: |
| 53 | # Basic conversion |
| 54 | python script/run_image2ppt_cli.py --input screenshot.png |
| 55 | |
| 56 | # With AI enhancement |
| 57 | python script/run_image2ppt_cli.py --input diagram.jpg --use-ai-edit --api-key sk-xxx |
| 58 | |
| 59 | # Custom style |
| 60 | python script/run_image2ppt_cli.py --input slide.png --use-ai-edit --style "现代简约风格" |
| 61 | |
| 62 | Environment Variables: |
| 63 | DF_API_URL - Default LLM API URL |
| 64 | DF_API_KEY - Default API key |
| 65 | DF_MODEL - Default text model name |
| 66 | """ |
| 67 | ) |
| 68 | |
| 69 | # Required arguments |
| 70 | parser.add_argument( |
| 71 | "--input", |
| 72 | required=True, |
| 73 | help="Input image file path (PNG/JPG/JPEG)" |
| 74 | ) |
| 75 | |
| 76 | # Optional arguments |
| 77 | parser.add_argument( |
| 78 | "--use-ai-edit", |
| 79 | action="store_true", |
| 80 | help="Enable AI enhancement (default: False)" |
| 81 | ) |
| 82 | |
| 83 | parser.add_argument( |
| 84 | "--api-url", |
| 85 | help="LLM API URL (default: from env DF_API_URL)" |
| 86 | ) |
| 87 | |
| 88 | parser.add_argument( |
| 89 | "--api-key", |
| 90 | help="LLM API key (default: from env DF_API_KEY)" |
| 91 | ) |
| 92 | |
| 93 | parser.add_argument( |
| 94 | "--image-api-url", |
| 95 | help="Image generation API URL (default: from env DF_IMAGE_API_URL)" |
| 96 | ) |
| 97 | |
| 98 | parser.add_argument( |
| 99 | "--image-api-key", |
| 100 | help="Image generation API key (default: from env DF_IMAGE_API_KEY)" |
| 101 | ) |
| 102 | |
| 103 | parser.add_argument( |