-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
49 lines (40 loc) · 1.29 KB
/
cli.py
File metadata and controls
49 lines (40 loc) · 1.29 KB
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
#!/usr/bin/env python3
"""Universal CLI entry point for Opinion CLI commands."""
import sys
from dotenv import load_dotenv
from commands.config import config
from commands.balance import balance
from commands.positions import positions
from commands.trades import trades
from commands.orders import orders
from commands.help import help
from commands.markets import markets
# Load environment variables from .env file
load_dotenv()
def main():
"""Main entry point that routes to the correct command based on script name."""
import os
# Use os.path.basename for cross-platform compatibility
script_name = os.path.basename(sys.argv[0])
# Define available commands mapping
COMMANDS = {
"config": config,
"balance": balance,
"positions": positions,
"trades": trades,
"orders": orders,
"help": help,
"markets": markets,
}
if script_name in COMMANDS:
COMMANDS[script_name]()
else:
# Show help when unknown command is used
print("❌ Unknown command.")
print("\n📚 Available commands:")
for cmd_name in COMMANDS.keys():
print(f" • {cmd_name}")
print("\n💡 Run 'uv run help' for detailed information")
sys.exit(1)
if __name__ == "__main__":
main()