def theme_cmd(data, buffer, args):
    """Callback for /theme command."""
    if args == '':
        weechat.command('', '/help %s' % SCRIPT_COMMAND)
        return weechat.WEECHAT_RC_OK
    argv = args.strip().split(' ', 1)
    if len(argv) == 0:
        return weechat.WEECHAT_RC_OK

    if argv[0] in ('list', 'install'):
        weechat.prnt('', '%s: action "%s" not developed' % (SCRIPT_NAME, argv[0]))
        return weechat.WEECHAT_RC_OK

    # check arguments
    if len(argv) < 2:
        if argv[0] in ('install', 'installfile', 'save', 'export'):
            weechat.prnt('', '%s: too few arguments for action "%s"'
                         % (SCRIPT_NAME, argv[0]))
            return weechat.WEECHAT_RC_OK

    # execute asked action
    if argv[0] == 'info':
        filename = None
        if len(argv) >= 2:
            filename = argv[1]
        theme = Theme(filename)
        if filename:
            theme.info('Info about theme "%s":' % filename)
        else:
            theme.info('Info about current theme:')
    elif argv[0] == 'show':
        filename = None
        if len(argv) >= 2:
            filename = argv[1]
        theme = Theme(filename)
        if filename:
            theme.show('Content of theme "%s":' % filename)
        else:
            theme.show('Content of current theme:')
    elif argv[0] == 'installfile':
        theme = Theme()
        theme.save(theme_config_get_undo())
        theme = Theme(argv[1])
        if theme.isok():
            theme.install()
    elif argv[0] == 'undo':
        theme = Theme(theme_config_get_undo())
        if theme.isok():
            theme.install()
    elif argv[0] == 'save':
        theme = Theme()
        theme.save(argv[1])
    elif argv[0] == 'backup':
        theme = Theme()
        theme.save(theme_config_get_backup())
    elif argv[0] == 'restore':
        theme = Theme(theme_config_get_backup())
        if theme.isok():
            theme.install()
    elif argv[0] == 'export':
        htheme = HtmlTheme()
        whitebg = False
        htmlfile = argv[1]
        argv2 = args.strip().split(' ', 2)
        if len(argv2) >= 3 and argv2[1] == 'white':
            whitebg = True
            htmlfile = argv2[2]
        htheme.save_html(htmlfile, whitebg)

    return weechat.WEECHAT_RC_OK