#!/usr/bin/env python

import argparse
import sys
from .helpers import * 

def main(): 

  parser = argparse.ArgumentParser()
  parser.add_argument("repo_name", help="githubuser/repo")
  parser.add_argument("-g", "--generate-html", action='store_true', help="Generate output as HTML")
  parser.add_argument("-l", "--limit", help="Limit to the last x Issues/Pull Requests", type=int, default=0)
  parser.add_argument("-c", "--show-contributors", action='store_true', help="Output the code contributors as well")
  parser.add_argument("-n", "--show-names", action='store_true', help="")
  args = parser.parse_args()  

  repo_name = args.repo_name

  if not repo_exists(repo_name): 
    print("Repo does not exist: %s" % repo_name)
    sys.exit(1)

  code_contributors = get_code_contributors(repo_name)
  code_commentors = get_code_commentors(repo_name, args.limit)

  non_code_contributors = []
  for user in code_commentors:
    user_name, avatar, name = user 
    if user not in code_contributors:
      non_code_contributors.append(user)

  print("Code contributions: %d" % len(code_contributors))

  if args.show_contributors:
    for user in code_contributors: 
      display_user_name(user, args)
  
  print("Non-code contributions: %d" % len(non_code_contributors))

  for user in non_code_contributors: 
    display_user_name(user, args)

  if args.generate_html:

    if not args.show_contributors and len(non_code_contributors) == 0:
      print("No non-code contributors for %s. No HTML output being generated.")
      sys.exit(0)

    html_file = "%s_contrib.html" % repo_name.replace("/", "_")
    f = open(html_file, "w")

    f.write("<style>.contrib{display:inline-block; padding: 10px;} .gen {padding-top: 40px}</style>")
    f.write("<h1>Non-code contributions for %s</h1>" % repo_name)

    if args.limit > 0:
      f.write("(for the most recent %d issues/pull requests)<br><br>" % args.limit)

    for user in non_code_contributors: 
      f.write(display_user_html(user, args))
  
    if args.show_contributors:
      f.write("<h1>Code contributions for %s</h1>\n" % repo_name)

      for user in code_contributors:
        f.write(display_user_html(user, args))

    f.write("<div class='gen'>Generated by <a href='https://github.com/glasnt/octohat'>octohat</a></div>")

    print("Generated HTML representation, saved to %s" % html_file)

if __name__ == "__main__":
    main()

@@ -1196,16 +1196,28 @@
 , args)%0A
+    print()%0A
   %0A  pri

Add an extra new line to console output if we're printing both lists