Main CLI entry point.
()
| 75 | |
| 76 | |
| 77 | def main(): |
| 78 | """Main CLI entry point.""" |
| 79 | parser = argparse.ArgumentParser( |
| 80 | prog="memos", |
| 81 | description="MemOS Command Line Interface", |
| 82 | ) |
| 83 | |
| 84 | # Create subparsers for different commands |
| 85 | subparsers = parser.add_subparsers(dest="command", help="Available commands") |
| 86 | |
| 87 | # Download examples command |
| 88 | examples_parser = subparsers.add_parser("download_examples", help="Download example files") |
| 89 | examples_parser.add_argument( |
| 90 | "--dest", |
| 91 | type=str, |
| 92 | default="./examples", |
| 93 | help="Destination directory for examples (default: ./examples)", |
| 94 | ) |
| 95 | |
| 96 | # Export API command |
| 97 | api_parser = subparsers.add_parser("export_openapi", help="Export OpenAPI schema to JSON file") |
| 98 | api_parser.add_argument( |
| 99 | "--output", |
| 100 | type=str, |
| 101 | default="openapi.json", |
| 102 | help="Output path for OpenAPI schema (default: openapi.json)", |
| 103 | ) |
| 104 | |
| 105 | # Parse arguments |
| 106 | args = parser.parse_args() |
| 107 | |
| 108 | # Handle commands |
| 109 | if args.command == "download_examples": |
| 110 | success = download_examples(args.dest) |
| 111 | exit(0 if success else 1) |
| 112 | elif args.command == "export_openapi": |
| 113 | success = export_openapi(args.output) |
| 114 | exit(0 if success else 1) |
| 115 | else: |
| 116 | parser.print_help() |
| 117 | |
| 118 | |
| 119 | if __name__ == "__main__": |