-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug
More file actions
executable file
·92 lines (79 loc) · 3.43 KB
/
bug
File metadata and controls
executable file
·92 lines (79 loc) · 3.43 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
# "click",
# ]
# ///
import subprocess
import click
def get_system_version() -> str:
sw_name = subprocess.run(["sw_vers", "--productName"], capture_output=True, text=True).stdout.strip()
sw_version = subprocess.run(["sw_vers", "--productVersion"], capture_output=True, text=True).stdout.strip()
xcode = subprocess.run(["xcodebuild", "-version"], capture_output=True, text=True).stdout.strip().replace("\n", " ")
return f"{sw_name} {sw_version} {xcode}"
def get_rust_version() -> str:
return subprocess.run(["rustc", "--version"], capture_output=True, text=True).stdout.strip()
def get_go_version() -> str:
return subprocess.run(["go", "version"], capture_output=True, text=True).stdout.strip()
def get_python3_version() -> str:
return subprocess.run(["python3", "--version"], capture_output=True, text=True).stdout.strip()
def get_node_version() -> str:
return subprocess.run(["node", "--version"], capture_output=True, text=True).stdout.strip()
def get_brew_version() -> str:
return subprocess.run(["brew", "--version"], capture_output=True, text=True).stdout.strip()
def get_terminal_version() -> str:
return subprocess.run(["ghostty", "--version"], capture_output=True, text=True).stdout.strip()
def show_version(version_key: str):
try:
if version_key == 'system':
name = 'System'
cmd_result = get_system_version()
elif version_key == 'rust':
name = 'Rust'
cmd_result = get_rust_version()
elif version_key == 'go':
name = 'Go'
cmd_result = get_go_version()
elif version_key == 'python3':
name = 'Python3'
cmd_result = get_python3_version()
elif version_key == 'node':
name = 'Node.js'
cmd_result = get_node_version()
elif version_key == 'brew':
name = 'Homebrew'
cmd_result = get_brew_version()
elif version_key == 'terminal':
name = 'Ghostty Terminal'
cmd_result = get_terminal_version()
else:
print(f"Unknown version key: {version_key}")
return
print(cmd_result)
except FileNotFoundError:
print(f"{name} is not installed or not found in PATH")
@click.command()
@click.option('--all', is_flag=True, help="Show all versions.")
@click.option('--system/--no-system', default=True, help="Show macOS and Xcode versions.")
@click.option('--rust/--no-rust', default=False, help="Show Rust version.")
@click.option('--go/--no-go', default=False, help="Show Go version.")
@click.option('--python3/--no-python3', default=False, help="Show Python3 version.")
@click.option('--node/--no-node', default=False, help="Show Node.js version.")
@click.option('--brew/--no-brew', default=False, help="Show Homebrew version.")
@click.option('--terminal/--no-terminal', default=False, help="Show Ghostty terminal version.")
def cli(all, system, rust, go, python3, node, brew, terminal):
if all:
system = rust = go = python3 = node = brew = terminal = True
for version_key, enabled in [
('system', system),
('rust', rust),
('go', go),
('python3', python3),
('node', node),
('brew', brew),
('terminal', terminal) # Always show terminal version
]:
if enabled:
show_version(version_key)
if __name__ == "__main__":
cli()