Changeset View
Changeset View
Standalone View
Standalone View
swh/fuse/cli.py
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | @click.option( | ||||
"-f", | "-f", | ||||
"--foreground", | "--foreground", | ||||
is_flag=True, | is_flag=True, | ||||
show_default=True, | show_default=True, | ||||
help="Run FUSE system in foreground instead of daemon", | help="Run FUSE system in foreground instead of daemon", | ||||
) | ) | ||||
@click.pass_context | @click.pass_context | ||||
def mount(ctx, swhids, path, config_file, foreground): | def mount(ctx, swhids, path, config_file, foreground): | ||||
""" Mount the Software Heritage archive at the given mount point """ | """Mount the Software Heritage archive at PATH | ||||
If specified, objects referenced by the given SWHIDs will be prefetched and used to | |||||
populate the virtual file system (VFS). Otherwise the VFS will be populated | |||||
on-demand, when accessing its content. | |||||
\b | |||||
Example: | |||||
\b | |||||
$ mkdir swhfs | |||||
$ swh fuse mount swhfs/ | |||||
$ grep printf swhfs/archive/swh:1:cnt:c839dea9e8e6f0528b468214348fee8669b305b2 | |||||
printf("Hello, World!"); | |||||
$ | |||||
""" | |||||
from swh.core import config | from swh.core import config | ||||
from swh.fuse import fuse | from swh.fuse import fuse | ||||
conf = config.read(config_file, DEFAULT_CONFIG) | conf = config.read(config_file, DEFAULT_CONFIG) | ||||
with ExitStack() as stack: | with ExitStack() as stack: | ||||
if not foreground: | if not foreground: | ||||
stack.enter_context(DaemonContext()) | stack.enter_context(DaemonContext()) | ||||
asyncio.run(fuse.main(swhids, path, conf)) | asyncio.run(fuse.main(swhids, path, conf)) |