Skip to content

Commit 074016a

Browse files
committed
Bug reports
1 parent f62f23d commit 074016a

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

bug

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env -S uv run --script
2+
# /// script
3+
# dependencies = [
4+
# "click",
5+
# ]
6+
# ///
7+
8+
import subprocess
9+
import click
10+
11+
def get_system_version() -> str:
12+
sw_name = subprocess.run(["sw_vers", "--productName"], capture_output=True, text=True).stdout.strip()
13+
sw_version = subprocess.run(["sw_vers", "--productVersion"], capture_output=True, text=True).stdout.strip()
14+
xcode = subprocess.run(["xcodebuild", "-version"], capture_output=True, text=True).stdout.strip().replace("\n", " ")
15+
return f"{sw_name} {sw_version} {xcode}"
16+
17+
def get_rust_version() -> str:
18+
return subprocess.run(["rustc", "--version"], capture_output=True, text=True).stdout.strip()
19+
20+
def get_go_version() -> str:
21+
return subprocess.run(["go", "version"], capture_output=True, text=True).stdout.strip()
22+
23+
def get_python3_version() -> str:
24+
return subprocess.run(["python3", "--version"], capture_output=True, text=True).stdout.strip()
25+
26+
def get_node_version() -> str:
27+
return subprocess.run(["node", "--version"], capture_output=True, text=True).stdout.strip()
28+
29+
def get_brew_version() -> str:
30+
return subprocess.run(["brew", "--version"], capture_output=True, text=True).stdout.strip()
31+
32+
def show_version(version_key: str):
33+
try:
34+
if version_key == 'system':
35+
name = 'System'
36+
cmd_result = get_system_version()
37+
elif version_key == 'rust':
38+
name = 'Rust'
39+
cmd_result = get_rust_version()
40+
elif version_key == 'go':
41+
name = 'Go'
42+
cmd_result = get_go_version()
43+
elif version_key == 'python3':
44+
name = 'Python3'
45+
cmd_result = get_python3_version()
46+
elif version_key == 'node':
47+
name = 'Node.js'
48+
cmd_result = get_node_version()
49+
elif version_key == 'brew':
50+
name = 'Homebrew'
51+
cmd_result = get_brew_version()
52+
else:
53+
print(f"Unknown version key: {version_key}")
54+
return
55+
56+
print(cmd_result)
57+
except FileNotFoundError:
58+
print(f"{name} is not installed or not found in PATH")
59+
60+
@click.command()
61+
@click.option('--all', is_flag=True, help="Show all versions.")
62+
@click.option('--system/--no-system', default=True, help="Show macOS and Xcode versions.")
63+
@click.option('--rust/--no-rust', default=False, help="Show Rust version.")
64+
@click.option('--go/--no-go', default=False, help="Show Go version.")
65+
@click.option('--python3/--no-python3', default=False, help="Show Python3 version.")
66+
@click.option('--node/--no-node', default=False, help="Show Node.js version.")
67+
@click.option('--brew/--no-brew', default=False, help="Show Homebrew version.")
68+
def cli(all, system, rust, go, python3, node, brew):
69+
if all:
70+
system = rust = go = python3 = node = brew = True
71+
72+
for version_key, enabled in [
73+
('system', system),
74+
('rust', rust),
75+
('go', go),
76+
('python3', python3),
77+
('node', node),
78+
('brew', brew)
79+
]:
80+
if enabled:
81+
show_version(version_key)
82+
83+
if __name__ == "__main__":
84+
cli()

0 commit comments

Comments
 (0)