Skip to content

Commit 7455828

Browse files
authored
Update vgmanmd.py
1 parent ae08b38 commit 7455828

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

doc/vgmanmd.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212

1313

1414
# parse short descriptions
15-
desc_inf = open('./doc/vgmanmd.desc.md', 'rt')
15+
try:
16+
desc_inf = open('./doc/vgmanmd.desc.md', 'rt')
17+
except FileNotFoundError:
18+
desc_inf = open('vgmanmd.desc.md', 'rt')
19+
1620
desc = {}
1721
cur_desc = ''
1822
cur_header = ''
@@ -68,10 +72,13 @@
6872
for cmd in cmds:
6973
print('## {cmd}\n\n'.format(cmd=cmd))
7074
try:
71-
# Try first with the help option to try and get all options described.
72-
ret = subprocess.run(['vg', cmd, '--help'], capture_output=True)
75+
# Try first with the help option to get all options described.
76+
# Use check=True to raise CalledProcessError on non-zero exit codes (e.g., when --help fails),
77+
# allowing us to fall back to running the command without --help.
78+
ret = subprocess.run(['vg', cmd, '--help'], capture_output=True, check=True)
7379
except subprocess.CalledProcessError:
74-
# Then try subcommand without -h because not everything has -h
80+
# Fallback to running the subcommand alone because some
81+
# vg subcommands (e.g., construct) don’t recognize --help
7582
ret = subprocess.run(['vg', cmd], capture_output=True)
7683
print('```')
7784
if cmd in desc:

0 commit comments

Comments
 (0)