libfuse/python-fuse

Documentation/Example of server.parser.add_option

glensc opened this issue · 1 comments

I'm trying to find anything to add new mount option.

Nothing useful found from README files, found something in examples/xml.py

    server.parser.add_option(mountopt="root", metavar="PATH", default='/',
                             help="mirror filesystem from under PATH [default: %default]")
    server.parse(values=server, errex=1)

    try:
        if server.fuse_args.mount_expected():
            os.chdir(server.root)
    except OSError:
        print("can't enter root of underlying filesystem", file=sys.stderr)
        sys.exit(1)

tried to replicate that to my program as

    server.parser.add_option(mountopt="cache_path", metavar="PATH", default="cache",
                             help="Cache downloads under PATH [default: %default]")
    server.parse(values=server, errex=1)
    server.main()

class MyFS(fuse.Fuse):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.cache_path = None

    def fsinit(self):
        print("fsinit, cache_path=", self.cache_path)

it appears in --help output as expected:

Options:
    --version              show program's version number and exit
    -h, --help             show this help message and exit
    -o opt,[opt...]        mount options
    -o cache_path=PATH     Cache downloads under PATH [default: cache]

yet cache_path remains None

from reading xml.py code, I understand the parse function adds it as property of object passed as values keyword argument, but in reality it does not seem to have effect.

Seems some unexpected behavior, the default="cache" argument to add_option() doesn't set the value to the default specified in that argument if no -o cache_path option is given.

the value remains to whatever was set in __init__