-o = options.Options(optspec)
-opt, flags, extra = o.parse(compat.argv[1:])
-if not opt.verbose:
- opt.verbose = 0
-
-# Set stderr to be line buffered, even if it's not connected to the console
-# so that we'll be able to see diagnostics in a timely fashion.
-errfd = sys.stderr.fileno()
-sys.stderr.flush()
-sys.stderr = os.fdopen(errfd, 'w', 1)
-
-if len(extra) != 1:
- o.fatal('only one mount point argument expected')
-
-git.check_repo_or_die()
-repo = LocalRepo()
-f = BupFs(repo=repo, verbose=opt.verbose, fake_metadata=(not opt.meta))
-
-# This is likely wrong, but the fuse module doesn't currently accept bytes
-f.fuse_args.mountpoint = extra[0]
-
-if opt.debug:
- f.fuse_args.add('debug')
-if opt.foreground:
- f.fuse_args.setmod('foreground')
-f.multithreaded = False
-if opt.allow_other:
- f.fuse_args.add('allow_other')
-f.main()
+
+def main(argv):
+ o = options.Options(optspec)
+ opt, flags, extra = o.parse_bytes(argv[1:])
+ if not opt.verbose:
+ opt.verbose = 0
+
+ # Set stderr to be line buffered, even if it's not connected to the console
+ # so that we'll be able to see diagnostics in a timely fashion.
+ errfd = sys.stderr.fileno()
+ sys.stderr.flush()
+ sys.stderr = os.fdopen(errfd, 'w', 1)
+
+ if len(extra) != 1:
+ o.fatal('only one mount point argument expected')
+
+ git.check_repo_or_die()
+ repo = LocalRepo()
+ f = BupFs(repo=repo, verbose=opt.verbose, fake_metadata=(not opt.meta))
+
+ # This is likely wrong, but the fuse module doesn't currently accept bytes
+ f.fuse_args.mountpoint = extra[0]
+
+ if opt.debug:
+ f.fuse_args.add('debug')
+ if opt.foreground:
+ f.fuse_args.setmod('foreground')
+ f.multithreaded = False
+ if opt.allow_other:
+ f.fuse_args.add('allow_other')
+ f.main()