@@ -32,7 +32,7 @@ def _load_config_file(config_path=None): | |||||
try: | try: | ||||
with open(cfg_path, "rb") as config_file: | with open(cfg_path, "rb") as config_file: | ||||
paths = config_file.read().split(b"\n") | |||||
paths = config_file.read().strip().split(b"\n") | |||||
return [path.decode("utf8") for path in paths] | return [path.decode("utf8") for path in paths] | ||||
except IOError: | except IOError: | ||||
return [] | return [] | ||||
@@ -118,10 +118,12 @@ def clean_bookmarks(config_path=None): | |||||
"""Delete any bookmarks that don't exist.""" | """Delete any bookmarks that don't exist.""" | ||||
bookmarks = _load_config_file(config_path) | bookmarks = _load_config_file(config_path) | ||||
if not bookmarks: | if not bookmarks: | ||||
print("You have no bookmarks to clean up.") | |||||
return | return | ||||
delete = [path for path in bookmarks if not os.path.isdir(path)] | delete = [path for path in bookmarks if not os.path.isdir(path)] | ||||
if not delete: | if not delete: | ||||
print("All of your bookmarks are valid.") | |||||
return | return | ||||
bookmarks = [path for path in bookmarks if path not in delete] | bookmarks = [path for path in bookmarks if path not in delete] | ||||
@@ -64,7 +64,7 @@ def main(): | |||||
'-l', '--list', dest="list_bookmarks", action="store_true", | '-l', '--list', dest="list_bookmarks", action="store_true", | ||||
help="list current bookmarks") | help="list current bookmarks") | ||||
group_b.add_argument( | group_b.add_argument( | ||||
'-e', '--clean', '--cleanup', dest="clean_bookmarks", | |||||
'-n', '--clean', '--cleanup', dest="clean_bookmarks", | |||||
action="store_true", help="delete any bookmarks that don't exist") | action="store_true", help="delete any bookmarks that don't exist") | ||||
group_b.add_argument( | group_b.add_argument( | ||||
'-b', '--bookmark-file', nargs="?", metavar="path", type=_decode, | '-b', '--bookmark-file', nargs="?", metavar="path", type=_decode, | ||||