File size: 2,601 Bytes
494c89b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python3
"""
Kiro Account Manager - Entry Point
Run this to start the standalone application
"""

import sys
import argparse
from pathlib import Path

# Setup paths for both development and bundled modes
if getattr(sys, 'frozen', False):
    # Running as bundled exe - add _MEIPASS to path
    base_path = Path(sys._MEIPASS)
    sys.path.insert(0, str(base_path))
else:
    # Development mode - add parent directory
    sys.path.insert(0, str(Path(__file__).parent))

from version import __version__


def main():
    parser = argparse.ArgumentParser(
        description='Kiro Account Manager - Standalone Application',
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog="""
Examples:
  python run.py                    # Start with default settings
  python run.py --port 8080        # Use custom port
  python run.py --no-browser       # Don't open browser automatically
  python run.py --host 0.0.0.0     # Allow external connections
        """
    )
    
    parser.add_argument(
        '--version', '-v',
        action='version',
        version=f'Kiro Account Manager v{__version__}'
    )
    
    parser.add_argument(
        '--host',
        default='127.0.0.1',
        help='Host to bind to (default: 127.0.0.1)'
    )
    
    parser.add_argument(
        '--port', '-p',
        type=int,
        default=8420,
        help='Port to listen on (default: 8420)'
    )
    
    parser.add_argument(
        '--no-browser',
        action='store_true',
        help='Do not open browser automatically'
    )
    
    parser.add_argument(
        '--debug',
        action='store_true',
        help='Enable debug mode'
    )
    
    parser.add_argument(
        '--check',
        action='store_true',
        help='Check if app can start (for CI testing)'
    )
    
    args = parser.parse_args()
    
    # Quick check mode for CI
    if args.check:
        try:
            from app.main import app
            print(f"✅ Kiro Account Manager v{__version__} - OK")
            sys.exit(0)
        except Exception as e:
            print(f"❌ Failed to load: {e}")
            sys.exit(1)
    
    # Check dependencies
    try:
        import fastapi
        import uvicorn
    except ImportError:
        print("\n❌ Missing dependencies!")
        print("   Run: pip install fastapi uvicorn[standard]\n")
        sys.exit(1)
    
    # Start application
    from app.main import run
    
    run(
        host=args.host,
        port=args.port,
        open_browser_flag=not args.no_browser
    )


if __name__ == '__main__':
    main()