Arguments: <new work directory path>

    Change current Paperwork's work directory.

    Does *not* update the index.
    You should run 'paperwork-shell rescan' after this command.

    Possible JSON replies:
        --
        {
            "status": "error", "exception": "yyy",
            "reason": "xxxx", "args": "(xxxx, )"
        }
        --
        {
            "status": "ok",
            "old_workdir": "file:///home/jflesch/papers",
            "new_workdir": "file:///tmp/papers",
        }

def cmd_switch_workdir(new_workdir):
    """
    Arguments: <new work directory path>

    Change current Paperwork's work directory.

    Does *not* update the index.
    You should run 'paperwork-shell rescan' after this command.

    Possible JSON replies:
        --
        {
            "status": "error", "exception": "yyy",
            "reason": "xxxx", "args": "(xxxx, )"
        }
        --
        {
            "status": "ok",
            "old_workdir": "file:///home/jflesch/papers",
            "new_workdir": "file:///tmp/papers",
        }
    """
    new_workdir = FS.safe(new_workdir)
    if not FS.exists(new_workdir) or not FS.isdir(new_workdir):
        sys.stderr.write("New work directory {} doesn't exists".format(
            new_workdir
        ))
        return
    pconfig = config.PaperworkConfig()
    pconfig.read()
    r = {
        'old_workdir': pconfig.settings['workdir'].value,
        'new_workdir': new_workdir
    }
    pconfig.settings['workdir'].value = new_workdir
    pconfig.write()
    reply(r)