-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathlist_commands.py
More file actions
42 lines (33 loc) · 1.15 KB
/
list_commands.py
File metadata and controls
42 lines (33 loc) · 1.15 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
import pathlib
import tomllib
import sys
def main():
commands_dir = pathlib.Path(".gemini/commands")
if not commands_dir.exists():
print(f"Directory not found: {commands_dir.absolute()}")
sys.exit(1)
files = sorted(commands_dir.glob("*.toml"))
if not files:
print("No .toml files found in .gemini/commands")
return
# Collect all commands and descriptions
commands = []
for file_path in files:
try:
with file_path.open("rb") as f:
data = tomllib.load(f)
description = data.get("description", "No description found")
commands.append((file_path.stem, description))
except Exception as e:
print(f"Error reading {file_path.name}: {e}", file=sys.stderr)
if not commands:
return
# Calculate max length for alignment
max_len = max(len(cmd[0]) for cmd in commands)
# Print aligned output
# We add a few spaces gap between command and description
gap = 3
for name, description in commands:
print(f"{name:<{max_len + gap}}{description}")
if __name__ == "__main__":
main()