diff --git a/swh/fuse/cli.py b/swh/fuse/cli.py --- a/swh/fuse/cli.py +++ b/swh/fuse/cli.py @@ -134,6 +134,33 @@ asyncio.run(fuse.main(swhids, path, ctx.obj["config"])) +@fuse.command() +@click.argument( + "path", + required=True, + metavar="PATH", + type=click.Path(exists=True, dir_okay=True, file_okay=False), +) +@click.pass_context +def umount(ctx, path): + """Unmount a mounted virtual file system. + + Note: this is equivalent to ``fusermount -u PATH``, which can be used to unmount any + FUSE-based virtual file system. See ``man fusermount3``. + + """ + import subprocess + + try: + subprocess.run(["fusermount", "-u", path], check=True) + except subprocess.CalledProcessError as err: + logging.error( + f"cannot unmount virtual file system: " + f"\"{' '.join(err.cmd)}\" returned exit status {err.returncode}" + ) + ctx.exit(1) + + @fuse.command() @click.pass_context def clean(ctx):