'mode MODE ?TABLE?: Sets output mode to one of'

def command_mode(self, cmd):

    if (len(cmd) in (1, 2)):
        w = cmd[0]
        if (w == 'tabs'):
            w = 'list'
        m = getattr(self, ('output_' + w), None)
        if (w != 'insert'):
            if (len(cmd) == 2):
                raise self.Error(("Output    mode    %s    doesn't    take    parameters" % cmd[0]))
        if m:
            self.output = m
            self.truncate = True
            if (cmd[0] == 'csv'):
                self.separator = ','
            elif (cmd[0] == 'tabs'):
                self.separator = ' DCTB '
            else:
                pass
            if (w == 'insert'):
                if (len(cmd) == 2):
                    self._output_table = cmd[1]
                else:
                    self._output_table = 'table'
                self._output_table = self._fmt_sql_identifier(self._output_table)
            return
    if (not self._output_modes):
        self._cache_output_modes()
    raise self.Error(('Expected    a    valid    output    mode:    ' + ',    '.join(self._output_modes)))
