#!/usr/bin/env python
import sys
import cloud
import optparse

from generate import generate_sudoku_with_unique_solution

def process_command_line(arguments):
    """Process the command line arguments"""
    parser = optparse.OptionParser(usage='Usage: %prog difficulty <options>')
    # Add parameters
    parser.add_option("-s", "--simulate",
                  action="store_true", dest="simulate", default=False,
                  help="Simulate on local host.")
    return parser.parse_args(arguments[1:])

if __name__ == '__main__':
    settings, args = process_command_line(sys.argv)
    difficulty = int(args[0])

    if settings.simulate:
        cloud.start_simulator()
    jid = cloud.call(generate_sudoku_with_unique_solution, difficulty)
    sudoku = cloud.result(jid)
    print 'Generated sudoku with unique solution:\n%r' % sudoku

