diff --git a/src/mvim/main.py b/src/mvim/main.py index 11ec89a..39424de 100644 --- a/src/mvim/main.py +++ b/src/mvim/main.py @@ -15,6 +15,11 @@ def main(): action="store_true", help="do not ignore entries starting with “.”.", ) + parser.add_argument( + "--directory", + action="store_true", + help="list directories themselves, not their contents", + ) parser.add_argument( "-s", "--follow-symlinks", diff --git a/src/mvim/mvim.py b/src/mvim/mvim.py index 60f534a..45cc3c1 100644 --- a/src/mvim/mvim.py +++ b/src/mvim/mvim.py @@ -85,6 +85,7 @@ def __init__( *, all_files=False, follow_symlinks=False, + directory=False, force=False, recursive=False, windows=False, @@ -95,6 +96,7 @@ def __init__( self.all_files = all_files self.follow_symlinks = follow_symlinks + self.directory = directory self.force = force self.recursive = recursive self.windows = windows @@ -135,15 +137,18 @@ def add(self, path): path = path.resolve().relative_to(Path.cwd()) if path.is_dir(): - self.oldnames.extend( - sorted( - [ - p - for p in path.iterdir() - if self.all_files or not p.as_posix().startswith(".") - ] + if self.directory: + self.oldnames.append(path) + else: + self.oldnames.extend( + sorted( + [ + p + for p in path.iterdir() + if self.all_files or not p.as_posix().startswith(".") + ] + ) ) - ) elif path.is_file() or path.is_symlink(): self.oldnames.append(path) else: