]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blobdiff - src/allmydata/scripts/cli.py
bin/tahoe: clean up global-vs-subcommand arguments like --node-directory
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / scripts / cli.py
index 233e3b1f6845162eec6047d5b4427ed0fc8dfe9e..5082685cfc568293a2329335f35a4b5fff66575c 100644 (file)
@@ -1,33 +1,31 @@
-import os.path, re, sys, fnmatch
+import os.path, re, fnmatch
 from twisted.python import usage
-from allmydata.scripts.common import BaseOptions, get_aliases
+from allmydata.scripts.common import get_aliases, get_default_nodedir, \
+     DEFAULT_ALIAS, BaseOptions
+from allmydata.util.encodingutil import argv_to_unicode, argv_to_abspath, quote_output
 
-NODEURL_RE=re.compile("http://([^:]*)(:([1-9][0-9]*))?")
+NODEURL_RE=re.compile("http(s?)://([^:]*)(:([1-9][0-9]*))?")
 
-class VDriveOptions(BaseOptions, usage.Options):
+_default_nodedir = get_default_nodedir()
+
+class VDriveOptions(BaseOptions):
     optParameters = [
-        ["node-directory", "d", "~/.tahoe",
-         "Look here to find out which Tahoe node should be used for all "
-         "operations. The directory should either contain a full Tahoe node, "
-         "or a file named node.url which points to some other Tahoe node. "
-         "It should also contain a file named private/aliases which contains "
-         "the mapping from alias name to root dirnode URI."
-         ],
         ["node-url", "u", None,
-         "URL of the tahoe node to use, a URL like \"http://127.0.0.1:3456\". "
+         "Specify the URL of the Tahoe gateway node, such as "
+         "'http://127.0.0.1:3456'. "
          "This overrides the URL found in the --node-directory ."],
         ["dir-cap", None, None,
-         "Which dirnode URI should be used as the 'tahoe' alias."]
+         "Specify which dirnode URI should be used as the 'tahoe' alias."]
         ]
 
     def postOptions(self):
+        self["quiet"] = self.parent["quiet"]
+        if self.parent['node-directory']:
+            self['node-directory'] = argv_to_abspath(self.parent['node-directory'])
+        else:
+            self['node-directory'] = _default_nodedir
+
         # compute a node-url from the existing options, put in self['node-url']
-        if self['node-directory']:
-            if sys.platform == 'win32' and self['node-directory'] == '~/.tahoe':
-                from allmydata.windows import registry
-                self['node-directory'] = registry.get_base_dir_path()
-            else:
-                self['node-directory'] = os.path.expanduser(self['node-directory'])
         if self['node-url']:
             if (not isinstance(self['node-url'], basestring)
                 or not NODEURL_RE.match(self['node-url'])):
@@ -43,49 +41,97 @@ class VDriveOptions(BaseOptions, usage.Options):
 
         aliases = get_aliases(self['node-directory'])
         if self['dir-cap']:
-            aliases["tahoe"] = self['dir-cap']
+            aliases[DEFAULT_ALIAS] = self['dir-cap']
         self.aliases = aliases # maps alias name to dircap
 
 
 class MakeDirectoryOptions(VDriveOptions):
+    optParameters = [
+        ("format", None, None, "Create a directory with the given format: SDMF or MDMF (case-insensitive)"),
+        ]
+
     def parseArgs(self, where=""):
-        self.where = where
+        self.where = argv_to_unicode(where)
+
+        if self['format']:
+            if self['format'].upper() not in ("SDMF", "MDMF"):
+                raise usage.UsageError("%s is an invalid format" % self['format'])
+
+    def getSynopsis(self):
+        return "Usage:  %s mkdir [options] [REMOTE_DIR]" % (self.command_name,)
+
     longdesc = """Create a new directory, either unlinked or as a subdirectory."""
 
 class AddAliasOptions(VDriveOptions):
     def parseArgs(self, alias, cap):
-        self.alias = alias
+        self.alias = argv_to_unicode(alias)
+        if self.alias.endswith(u':'):
+            self.alias = self.alias[:-1]
         self.cap = cap
 
     def getSynopsis(self):
-        return "%s add-alias ALIAS DIRCAP" % (os.path.basename(sys.argv[0]),)
+        return "Usage:  %s add-alias [options] ALIAS[:] DIRCAP" % (self.command_name,)
 
     longdesc = """Add a new alias for an existing directory."""
 
 class CreateAliasOptions(VDriveOptions):
     def parseArgs(self, alias):
-        self.alias = alias
+        self.alias = argv_to_unicode(alias)
+        if self.alias.endswith(u':'):
+            self.alias = self.alias[:-1]
 
     def getSynopsis(self):
-        return "%s create-alias ALIAS" % (os.path.basename(sys.argv[0]),)
+        return "Usage:  %s create-alias [options] ALIAS[:]" % (self.command_name,)
 
     longdesc = """Create a new directory and add an alias for it."""
 
-class ListAliasOptions(VDriveOptions):
+class ListAliasesOptions(VDriveOptions):
+    def getSynopsis(self):
+        return "Usage:  %s list-aliases [options]" % (self.command_name,)
+
     longdesc = """Display a table of all configured aliases."""
 
 class ListOptions(VDriveOptions):
     optFlags = [
-        ("long", "l", "Use long format: show file sizes, and timestamps"),
-        ("uri", "u", "Show file/directory URIs"),
-        ("readonly-uri", None, "Show readonly file/directory URIs"),
-        ("classify", "F", "Append '/' to directory names, and '*' to mutable"),
-        ("json", None, "Show the raw JSON output"),
+        ("long", "l", "Use long format: show file sizes, and timestamps."),
+        ("uri", "u", "Show file/directory URIs."),
+        ("readonly-uri", None, "Show read-only file/directory URIs."),
+        ("classify", "F", "Append '/' to directory names, and '*' to mutable."),
+        ("json", None, "Show the raw JSON output."),
         ]
     def parseArgs(self, where=""):
-        self.where = where
+        self.where = argv_to_unicode(where)
+
+    def getSynopsis(self):
+        return "Usage:  %s ls [options] [PATH]" % (self.command_name,)
+
+    longdesc = """
+    List the contents of some portion of the grid.
+
+    If PATH is omitted, "tahoe:" is assumed.
 
-    longdesc = """List the contents of some portion of the grid."""
+    When the -l or --long option is used, each line is shown in the
+    following format:
+
+    drwx <size> <date/time> <name in this directory>
+
+    where each of the letters on the left may be replaced by '-'.
+    If 'd' is present, it indicates that the object is a directory.
+    If the 'd' is replaced by a '?', the object type is unknown.
+    'rwx' is a Unix-like permissions mask: if the mask includes 'w',
+    then the object is writeable through its link in this directory
+    (note that the link might be replaceable even if the object is
+    not writeable through the current link).
+    The 'x' is a legacy of Unix filesystems. In Tahoe it is used
+    only to indicate that the contents of a directory can be listed.
+
+    Directories have no size, so their size field is shown as '-'.
+    Otherwise the size of the file, when known, is given in bytes.
+    The size of mutable files or unknown objects is shown as '?'.
+
+    The date/time shows when this link in the Tahoe filesystem was
+    last modified.
+    """
 
 class GetOptions(VDriveOptions):
     def parseArgs(self, arg1, arg2=None):
@@ -94,13 +140,18 @@ class GetOptions(VDriveOptions):
         # tahoe get FOO bar              # write to local file
         # tahoe get tahoe:FOO bar        # same
 
-        self.from_file = arg1
-        self.to_file = arg2
+        self.from_file = argv_to_unicode(arg1)
+
+        if arg2:
+            self.to_file = argv_to_unicode(arg2)
+        else:
+            self.to_file = None
+
         if self.to_file == "-":
             self.to_file = None
 
     def getSynopsis(self):
-        return "%s get REMOTE_FILE LOCAL_FILE" % (os.path.basename(sys.argv[0]),)
+        return "Usage:  %s get [options] REMOTE_FILE LOCAL_FILE" % (self.command_name,)
 
     longdesc = """
     Retrieve a file from the grid and write it to the local filesystem. If
@@ -120,40 +171,51 @@ Examples:
 
 class PutOptions(VDriveOptions):
     optFlags = [
-        ("mutable", "m", "Create a mutable file instead of an immutable one."),
+        ("mutable", "m", "Create a mutable file instead of an immutable one (like --format=SDMF)"),
+        ]
+    optParameters = [
+        ("format", None, None, "Create a file with the given format: SDMF and MDMF for mutable, CHK (default) for immutable. (case-insensitive)"),
         ]
 
     def parseArgs(self, arg1=None, arg2=None):
         # see Examples below
 
         if arg1 is not None and arg2 is not None:
-            self.from_file = arg1
-            self.to_file = arg2
+            self.from_file = argv_to_unicode(arg1)
+            self.to_file =  argv_to_unicode(arg2)
         elif arg1 is not None and arg2 is None:
-            self.from_file = arg1 # might be "-"
+            self.from_file = argv_to_unicode(arg1) # might be "-"
             self.to_file = None
         else:
             self.from_file = None
             self.to_file = None
-        if self.from_file == "-":
+        if self.from_file == u"-":
             self.from_file = None
 
+        if self['format']:
+            if self['format'].upper() not in ("SDMF", "MDMF", "CHK"):
+                raise usage.UsageError("%s is an invalid format" % self['format'])
+
     def getSynopsis(self):
-        return "%s put LOCAL_FILE REMOTE_FILE" % (os.path.basename(sys.argv[0]),)
+        return "Usage:  %s put [options] LOCAL_FILE REMOTE_FILE" % (self.command_name,)
 
     longdesc = """
     Put a file into the grid, copying its contents from the local filesystem.
     If REMOTE_FILE is missing, upload the file but do not link it into a
     directory; also print the new filecap to stdout. If LOCAL_FILE is missing
     or '-', data will be copied from stdin. REMOTE_FILE is assumed to start
-    with tahoe: unless otherwise specified."""
+    with tahoe: unless otherwise specified.
+
+    If the destination file already exists and is mutable, it will be modified
+    in-place, whether or not --mutable is specified. (--mutable only affects
+    creation of new files.)"""
 
     def getUsage(self, width=None):
         t = VDriveOptions.getUsage(self, width)
         t += """
 Examples:
  % cat FILE | tahoe put                # create unlinked file from stdin
- % cat FILE | tahoe -                  # same
+ % cat FILE | tahoe put -              # same
  % tahoe put bar                       # create unlinked file from local 'bar'
  % cat FILE | tahoe put - FOO          # create tahoe:FOO from stdin
  % tahoe put bar FOO                   # copy local 'bar' to tahoe:FOO
@@ -170,13 +232,16 @@ class CpOptions(VDriveOptions):
          "When copying to local files, write out filecaps instead of actual "
          "data (only useful for debugging and tree-comparison purposes)."),
         ]
+
     def parseArgs(self, *args):
         if len(args) < 2:
             raise usage.UsageError("cp requires at least two arguments")
-        self.sources = args[:-1]
-        self.destination = args[-1]
+        self.sources = map(argv_to_unicode, args[:-1])
+        self.destination = argv_to_unicode(args[-1])
+
     def getSynopsis(self):
-        return "Usage: tahoe [options] cp FROM.. TO"
+        return "Usage: %s cp [options] FROM.. TO" % (self.command_name,)
+
     longdesc = """
     Use 'tahoe cp' to copy files between a local filesystem and a Tahoe grid.
     Any FROM/TO arguments that begin with an alias indicate Tahoe-side
@@ -193,29 +258,34 @@ class CpOptions(VDriveOptions):
 
     You can also use a dircap as either FROM or TO target:
 
-    tahoe cp URI:DIR2-RO:j74uhg25nwdpjpacl6rkat2yhm:kav7ijeft5h7r7rxdp5bgtlt3viv32yabqajkrdykozia5544jqa/wiki.html ./   # copy Zooko's wiki page to a local file
+    tahoe cp URI:DIR2-RO:ixqhc4kdbjxc7o65xjnveoewym:5x6lwoxghrd5rxhwunzavft2qygfkt27oj3fbxlq4c6p45z5uneq/blog.html ./   # copy Zooko's wiki page to a local file
 
-    This command still has some limitations: symlinks, special files (device
-    nodes, named pipes), and non-ASCII filenames are not handled very well.
-    Arguments should probably not have trailing slashes. 'tahoe cp' does not
-    behave as much like /bin/cp as you would wish, especially with respect to
-    trailing slashes.
+    This command still has some limitations: symlinks and special files
+    (device nodes, named pipes) are not handled very well. Arguments should
+    probably not have trailing slashes. 'tahoe cp' does not behave as much
+    like /bin/cp as you would wish, especially with respect to trailing
+    slashes.
     """
 
-class RmOptions(VDriveOptions):
+class UnlinkOptions(VDriveOptions):
     def parseArgs(self, where):
-        self.where = where
+        self.where = argv_to_unicode(where)
+
+    def getSynopsis(self):
+        return "Usage:  %s unlink [options] REMOTE_FILE" % (self.command_name,)
 
+class RmOptions(UnlinkOptions):
     def getSynopsis(self):
-        return "%s rm REMOTE_FILE" % (os.path.basename(sys.argv[0]),)
+        return "Usage:  %s rm [options] REMOTE_FILE" % (self.command_name,)
 
 class MvOptions(VDriveOptions):
     def parseArgs(self, frompath, topath):
-        self.from_file = frompath
-        self.to_file = topath
+        self.from_file = argv_to_unicode(frompath)
+        self.to_file = argv_to_unicode(topath)
 
     def getSynopsis(self):
-        return "%s mv FROM TO" % (os.path.basename(sys.argv[0]),)
+        return "Usage:  %s mv [options] FROM TO" % (self.command_name,)
+
     longdesc = """
     Use 'tahoe mv' to move files that are already on the grid elsewhere on
     the grid, e.g., 'tahoe mv alias:some_file alias:new_file'.
@@ -230,11 +300,33 @@ class MvOptions(VDriveOptions):
 
 class LnOptions(VDriveOptions):
     def parseArgs(self, frompath, topath):
-        self.from_file = frompath
-        self.to_file = topath
+        self.from_file = argv_to_unicode(frompath)
+        self.to_file = argv_to_unicode(topath)
 
     def getSynopsis(self):
-        return "%s ln FROM TO" % (os.path.basename(sys.argv[0]),)
+        return "Usage:  %s ln [options] FROM_LINK TO_LINK" % (self.command_name,)
+
+    longdesc = """
+    Use 'tahoe ln' to duplicate a link (directory entry) already on the grid
+    to elsewhere on the grid. For example 'tahoe ln alias:some_file
+    alias:new_file'. causes 'alias:new_file' to point to the same object that
+    'alias:some_file' points to.
+
+    (The argument order is the same as Unix ln. To remember the order, you
+    can think of this command as copying a link, rather than copying a file
+    as 'tahoe cp' does. Then the argument order is consistent with that of
+    'tahoe cp'.)
+
+    When linking a remote file into a remote directory, you'll need to append
+    a '/' to the name of the remote directory, e.g. 'tahoe ln tahoe:file1
+    tahoe:dir/' (which is shorthand for 'tahoe ln tahoe:file1
+    tahoe:dir/file1'). If you forget the '/', e.g. 'tahoe ln tahoe:file1
+    tahoe:dir', the 'ln' command will refuse to overwrite the 'tahoe:dir'
+    directory, and will exit with an error.
+
+    Note that it is not possible to use this command to create links between
+    local and remote files.
+    """
 
 class BackupConfigurationError(Exception):
     pass
@@ -255,27 +347,28 @@ class BackupOptions(VDriveOptions):
         self['exclude'] = set()
 
     def parseArgs(self, localdir, topath):
-        self.from_dir = localdir
-        self.to_dir = topath
+        self.from_dir = argv_to_unicode(localdir)
+        self.to_dir = argv_to_unicode(topath)
 
-    def getSynopsis(Self):
-        return "%s backup FROM ALIAS:TO" % os.path.basename(sys.argv[0])
+    def getSynopsis(self):
+        return "Usage:  %s backup [options] FROM ALIAS:TO" % (self.command_name,)
 
     def opt_exclude(self, pattern):
         """Ignore files matching a glob pattern. You may give multiple
         '--exclude' options."""
-        g = pattern.strip()
+        g = argv_to_unicode(pattern).strip()
         if g:
             exclude = self['exclude']
             exclude.add(g)
 
     def opt_exclude_from(self, filepath):
         """Ignore file matching glob patterns listed in file, one per
-        line."""
+        line. The file is assumed to be in the argv encoding."""
+        abs_filepath = argv_to_abspath(filepath)
         try:
-            exclude_file = file(filepath)
+            exclude_file = file(abs_filepath)
         except:
-            raise BackupConfigurationError('Error opening exclude file %r.' % filepath)
+            raise BackupConfigurationError('Error opening exclude file %s.' % quote_output(abs_filepath))
         try:
             for line in exclude_file:
                 self.opt_exclude(line)
@@ -283,9 +376,9 @@ class BackupOptions(VDriveOptions):
             exclude_file.close()
 
     def opt_exclude_vcs(self):
-        """Exclude files and directories used by following version
-        control systems: 'CVS', 'RCS', 'SCCS', 'SVN', 'Arch',
-        'Bazaar', 'Mercurial', and 'Darcs'."""
+        """Exclude files and directories used by following version control
+        systems: CVS, RCS, SCCS, Git, SVN, Arch, Bazaar(bzr), Mercurial,
+        Darcs."""
         for pattern in self.vcs_patterns:
             self.opt_exclude(pattern)
 
@@ -309,27 +402,31 @@ class BackupOptions(VDriveOptions):
     TO/Archives/(new) TO/Latest'."""
 
 class WebopenOptions(VDriveOptions):
+    optFlags = [
+        ("info", "i", "Open the t=info page for the file"),
+        ]
     def parseArgs(self, where=''):
-        self.where = where
+        self.where = argv_to_unicode(where)
 
     def getSynopsis(self):
-        return "%s webopen [ALIAS:PATH]" % (os.path.basename(sys.argv[0]),)
+        return "Usage:  %s webopen [options] [ALIAS:PATH]" % (self.command_name,)
 
     longdesc = """Open a web browser to the contents of some file or
-    directory on the grid."""
+    directory on the grid. When run without arguments, open the Welcome
+    page."""
 
 class ManifestOptions(VDriveOptions):
     optFlags = [
-        ("storage-index", "s", "Only print storage index strings, not pathname+cap"),
-        ("verify-cap", None, "Only print verifycap, not pathname+cap"),
-        ("repair-cap", None, "Only print repaircap, not pathname+cap"),
-        ("raw", "r", "Display raw JSON data instead of parsed"),
+        ("storage-index", "s", "Only print storage index strings, not pathname+cap."),
+        ("verify-cap", None, "Only print verifycap, not pathname+cap."),
+        ("repair-cap", None, "Only print repaircap, not pathname+cap."),
+        ("raw", "r", "Display raw JSON data instead of parsed."),
         ]
     def parseArgs(self, where=''):
-        self.where = where
+        self.where = argv_to_unicode(where)
 
     def getSynopsis(self):
-        return "%s manifest [ALIAS:PATH]" % (os.path.basename(sys.argv[0]),)
+        return "Usage:  %s manifest [options] [ALIAS:PATH]" % (self.command_name,)
 
     longdesc = """Print a list of all files and directories reachable from
     the given starting point."""
@@ -339,26 +436,26 @@ class StatsOptions(VDriveOptions):
         ("raw", "r", "Display raw JSON data instead of parsed"),
         ]
     def parseArgs(self, where=''):
-        self.where = where
+        self.where = argv_to_unicode(where)
 
     def getSynopsis(self):
-        return "%s stats [ALIAS:PATH]" % (os.path.basename(sys.argv[0]),)
+        return "Usage:  %s stats [options] [ALIAS:PATH]" % (self.command_name,)
 
     longdesc = """Print statistics about of all files and directories
     reachable from the given starting point."""
 
 class CheckOptions(VDriveOptions):
     optFlags = [
-        ("raw", None, "Display raw JSON data instead of parsed"),
-        ("verify", None, "Verify all hashes, instead of merely querying share presence"),
-        ("repair", None, "Automatically repair any problems found"),
-        ("add-lease", None, "Add/renew lease on all shares"),
+        ("raw", None, "Display raw JSON data instead of parsed."),
+        ("verify", None, "Verify all hashes, instead of merely querying share presence."),
+        ("repair", None, "Automatically repair any problems found."),
+        ("add-lease", None, "Add/renew lease on all shares."),
         ]
     def parseArgs(self, where=''):
-        self.where = where
+        self.where = argv_to_unicode(where)
 
     def getSynopsis(self):
-        return "%s check [ALIAS:PATH]" % (os.path.basename(sys.argv[0]),)
+        return "Usage:  %s check [options] [ALIAS:PATH]" % (self.command_name,)
 
     longdesc = """
     Check a single file or directory: count how many shares are available and
@@ -367,17 +464,17 @@ class CheckOptions(VDriveOptions):
 
 class DeepCheckOptions(VDriveOptions):
     optFlags = [
-        ("raw", None, "Display raw JSON data instead of parsed"),
-        ("verify", None, "Verify all hashes, instead of merely querying share presence"),
-        ("repair", None, "Automatically repair any problems found"),
-        ("add-lease", None, "Add/renew lease on all shares"),
+        ("raw", None, "Display raw JSON data instead of parsed."),
+        ("verify", None, "Verify all hashes, instead of merely querying share presence."),
+        ("repair", None, "Automatically repair any problems found."),
+        ("add-lease", None, "Add/renew lease on all shares."),
         ("verbose", "v", "Be noisy about what is happening."),
         ]
     def parseArgs(self, where=''):
-        self.where = where
+        self.where = argv_to_unicode(where)
 
     def getSynopsis(self):
-        return "%s deep-check [ALIAS:PATH]" % (os.path.basename(sys.argv[0]),)
+        return "Usage:  %s deep-check [options] [ALIAS:PATH]" % (self.command_name,)
 
     longdesc = """
     Check all files and directories reachable from the given starting point
@@ -385,23 +482,24 @@ class DeepCheckOptions(VDriveOptions):
     Optionally repair any problems found."""
 
 subCommands = [
-    ["mkdir", None, MakeDirectoryOptions, "Create a new directory"],
-    ["add-alias", None, AddAliasOptions, "Add a new alias cap"],
-    ["create-alias", None, CreateAliasOptions, "Create a new alias cap"],
-    ["list-aliases", None, ListAliasOptions, "List all alias caps"],
-    ["ls", None, ListOptions, "List a directory"],
+    ["mkdir", None, MakeDirectoryOptions, "Create a new directory."],
+    ["add-alias", None, AddAliasOptions, "Add a new alias cap."],
+    ["create-alias", None, CreateAliasOptions, "Create a new alias cap."],
+    ["list-aliases", None, ListAliasesOptions, "List all alias caps."],
+    ["ls", None, ListOptions, "List a directory."],
     ["get", None, GetOptions, "Retrieve a file from the grid."],
     ["put", None, PutOptions, "Upload a file into the grid."],
-    ["cp", None, CpOptions, "Copy one or more files."],
-    ["rm", None, RmOptions, "Unlink a file or directory on the grid."],
+    ["cp", None, CpOptions, "Copy one or more files or directories."],
+    ["unlink", None, UnlinkOptions, "Unlink a file or directory on the grid."],
+    ["rm", None, RmOptions, "Unlink a file or directory on the grid (same as unlink)."],
     ["mv", None, MvOptions, "Move a file within the grid."],
-    ["ln", None, LnOptions, "Make an additional link to an existing file."],
+    ["ln", None, LnOptions, "Make an additional link to an existing file or directory."],
     ["backup", None, BackupOptions, "Make target dir look like local dir."],
     ["webopen", None, WebopenOptions, "Open a web browser to a grid file or directory."],
-    ["manifest", None, ManifestOptions, "List all files/directories in a subtree"],
-    ["stats", None, StatsOptions, "Print statistics about all files/directories in a subtree"],
-    ["check", None, CheckOptions, "Check a single file or directory"],
-    ["deep-check", None, DeepCheckOptions, "Check all files/directories reachable from a starting point"],
+    ["manifest", None, ManifestOptions, "List all files/directories in a subtree."],
+    ["stats", None, StatsOptions, "Print statistics about all files/directories in a subtree."],
+    ["check", None, CheckOptions, "Check a single file or directory."],
+    ["deep-check", None, DeepCheckOptions, "Check all files/directories reachable from a starting point."],
     ]
 
 def mkdir(options):
@@ -453,11 +551,14 @@ def cp(options):
     rc = tahoe_cp.copy(options)
     return rc
 
-def rm(options):
-    from allmydata.scripts import tahoe_rm
-    rc = tahoe_rm.rm(options)
+def unlink(options, command="unlink"):
+    from allmydata.scripts import tahoe_unlink
+    rc = tahoe_unlink.unlink(options, command=command)
     return rc
 
+def rm(options):
+    return unlink(options, command="rm")
+
 def mv(options):
     from allmydata.scripts import tahoe_mv
     rc = tahoe_mv.mv(options, mode="move")
@@ -507,6 +608,7 @@ dispatch = {
     "get": get,
     "put": put,
     "cp": cp,
+    "unlink": unlink,
     "rm": rm,
     "mv": mv,
     "ln": ln,