-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
71 lines (58 loc) · 2.03 KB
/
main.py
File metadata and controls
71 lines (58 loc) · 2.03 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
"""VS Code Discord RPC — Advanced Rich Presence with smart activity detection.
Usage:
python main.py # start with default config.toml
python main.py -c my_config.toml # use a custom config file
python main.py --help # show all options
"""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
def main() -> None:
parser = argparse.ArgumentParser(
description="Advanced Discord Rich Presence for VS Code",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=(
"Template variables for config.toml:\n"
" {workspace} project name\n"
" {filename} current file\n"
" {language} detected language\n"
" {language_icon} Discord asset key\n"
" {activity} auto-detected activity\n"
" {branch} git branch\n"
" {file_size} file size\n"
" {line_count} line count\n"
),
)
parser.add_argument(
"-c", "--config",
type=Path,
default=None,
help="path to config.toml (default: ./config.toml)",
)
parser.add_argument(
"--version",
action="version",
version="vscode-discord-rpc 1.0.0",
)
args = parser.parse_args()
# validate Python version
if sys.version_info < (3, 11):
print("Error: Python 3.11+ is required (for tomllib).", file=sys.stderr)
sys.exit(1)
from rpc.app import App
app = App(config_path=args.config)
if not app.config.client_id:
print(
"Error: No Discord client_id set.\n"
" 1. Go to https://discord.com/developers/applications\n"
" 2. Create an application (or use an existing one)\n"
" 3. Copy the Application ID\n"
" 4. Set it in config.toml under [discord] client_id\n",
file=sys.stderr,
)
sys.exit(1)
app.run()
if __name__ == "__main__":
main()