--- /dev/null
+
+from twisted.python import usage, failure
+from allmydata.scripts.common import BaseOptions
+from .common import BaseOptions, BasedirOptions
+
+class CreateOptions(BasedirOptions):
+ nickname = None
+ localdir = None
+ def parseArgs(self, alias, nickname=None, localdir=None):
+ BasedirOptions.parseArgs(self)
+ self.alias = alias
+ self.nickname = nickname
+ self.localdir = localdir
+ if self.nickname and not self.localdir:
+ raise usage.UsageError("must provide both")
+ synopsis = "MAGIC_ALIAS: [NICKNAME LOCALDIR]"
+
+def create(options):
+ pass
+
+class InviteOptions(BasedirOptions):
+ pass
+
+def invite(options):
+ pass
+
+class JoinOptions(BasedirOptions):
+ pass
+
+def join(options):
+ pass
+
+class MagicFolderCommand(BaseOptions):
+ subCommands = [
+ ["create", None, CreateOptions, "Create a Magic-Folder."],
+ ["invite", None, InviteOptions, "Invite someone to a Magic-Folder."],
+ ["join", None, JoinOptions, "Join a Magic-Folder."],
+ ]
+ def postOptions(self):
+ if not hasattr(self, 'subOptions'):
+ raise usage.UsageError("must specify a subcommand")
+ def getSynopsis(self):
+ return "Usage: tahoe [global-options] magic SUBCOMMAND"
+ def getUsage(self, width=None):
+ t = BaseOptions.getUsage(self, width)
+ t += """\
+Please run e.g. 'tahoe magic-folder create --help' for more details on each
+subcommand.
+"""
+ return t
+
+subDispatch = {
+ "create": create,
+ "invite": invite,
+ "join": join,
+}
+
+def do_magic_folder(options):
+ so = options.subOptions
+ so.stdout = options.stdout
+ so.stderr = options.stderr
+ f = subDispatch[options.subCommand]
+ return f(so)
+
+subCommands = [
+ ["magic-folder", None, MagicFolderCommand, "magic-folder subcommands: use 'tahoe magic-folder' for a list."],
+]
+
+dispatch = {
+ "magic-folder": do_magic_folder,
+}
from twisted.python import usage
from allmydata.scripts.common import get_default_nodedir
-from allmydata.scripts import debug, create_node, startstop_node, cli, keygen, stats_gatherer, admin
+from allmydata.scripts import debug, create_node, startstop_node, cli, keygen, stats_gatherer, admin, magic_folder_cli
from allmydata.util.encodingutil import quote_output, quote_local_unicode_path, get_io_encoding
def GROUP(s):
+ debug.subCommands
+ GROUP("Using the filesystem")
+ cli.subCommands
+ + magic_folder_cli.subCommands
)
optFlags = [
rc = admin.dispatch[command](so)
elif command in cli.dispatch:
rc = cli.dispatch[command](so)
+ elif command in magic_folder_cli.dispatch:
+ rc = magic_folder_cli.dispatch[command](so)
elif command in ac_dispatch:
rc = ac_dispatch[command](so, stdout, stderr)
else: