code: def stats(path, fmt, nocolor, timezones, utc, noprogress, most_common, resolve, length):
      
      with colorize_output(nocolor):
          try:
              chat_history = _process_history(
                  path=path, thread='', timezones=timezones,
                  utc=utc, noprogress=noprogress, resolve=resolve)
          except ProcessingFailure:
              return
          statistics = ChatHistoryStatistics(
              chat_history, most_common=None if most_common < 0 else most_common)
          if fmt == 'text':
              statistics.write_text(sys.stdout, -1 if length < 0 else length)
          elif fmt == 'json':
              statistics.write_json(sys.stdout)
          elif fmt == 'pretty-json':
              statistics.write_json(sys.stdout, pretty=True)
          elif fmt == 'yaml':
              statistics.write_yaml(sys.stdout)
docs: Analysis of Facebook chat history.