Skip to content

Commit bad7bef

Browse files
committed
util: create ~/.manpath when missing for -m true
Previously update_mandb_path() silently returned if ~/.manpath did not exist, so 'cppman -m true' had no effect on a fresh system and users had to 'touch ~/.manpath' first (#136, #98). Catch FileNotFoundError specifically and continue with an empty file so the MANDATORY_MANPATH / MANDB_MAP entries are written. Also clarify the help text for -r/--rebuild-index, which has always rebuilt both sources rather than only the configured one (#154).
1 parent 0dd6733 commit bad7bef

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

bin/cppman

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def main():
8888
"The default value is 'vim'."),
8989
make_option('-r', '--rebuild-index', action='store_true',
9090
dest='rebuild_index', default=False,
91-
help="rebuild index database for the selected source, "
92-
"either 'cppreference.com' or 'cplusplus.com'."),
91+
help="rebuild index database from both sources "
92+
"('cppreference.com' and 'cplusplus.com')."),
9393
make_option('-v', '--version', action='store_true', dest='version',
9494
default=False, help='Show version information.'),
9595
make_option('--force-columns', action='store', dest='force_columns',

cppman/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ def update_mandb_path():
4141

4242
lines = []
4343

44-
""" read all lines """
44+
""" read all lines if the file already exists """
4545
try:
4646
with open(manpath_file, 'r') as f:
4747
lines = f.readlines()
48-
except IOError:
49-
return
48+
except FileNotFoundError:
49+
pass
5050

5151
""" remove MANDATORY_MANPATH and MANDB_MAP entry """
5252
lines = [line for line in lines if man_dir not in line]

0 commit comments

Comments
 (0)