Set up the command-line options.

def setup_parser():
    '''Set up the command-line options.'''
    p = argparse.ArgumentParser(description='Create and manage a \
SimplyStatic site.')
    subparsers = p.add_subparsers(help='commands', dest='command')

    # aliases are not supported in 2.7 for add_parser
    # init command
    init_cmd_parser = subparsers.add_parser('init',
                        help="Initialize a SimplyStatic directory structure")

    init_cmd_parser.add_argument('-d', '--dirname', action='store',
                                 help='Directory to initialize')

    init_cmd_parser.add_argument('-r', '--randomsite', action='store_true',
                                 help='Add random pages to the site (useful for testing)')

    init_cmd_parser.add_argument('-n', '--numpages', action='store',type=int, default = 20,
                                 help='Number of random pages to add to the site.')

    # add command
    add_cmd_parser = subparsers.add_parser('add',
                                           help='Add a page to the site.')
    add_cmd_parser.add_argument('title', help="Title for the page",
                                action='store')

    add_cmd_parser.add_argument('-d', '--dirname',
        help="Directory of site root, or any place under site root.",
        action='store')

    generate_cmd_parser = subparsers.add_parser('gen',
                                           help='Generates the site.')
    generate_cmd_parser.add_argument('-d', '--dirname',
        help="Directory of site root, or any place under site root.",
        action='store')

    # rename command
    rename_cmd_parser = subparsers.add_parser('rename',
                                    help='Renames a page in the site.')
    rename_cmd_parser.add_argument('slug', 
                            help="Slug of the page to be renamed",
                            action='store')
    rename_cmd_parser.add_argument('newtitle',
                help="New title in quotes (*NOT* a slug) for the page.",
                action='store')
    rename_cmd_parser.add_argument('-d', '--dirname', 
            help="Directory of site root, or any place under site root.",
            action='store')

    # servecommand

    serve_cmd_parser = subparsers.add_parser('serve',
                                    help='Serves the site on localhost.')
    serve_cmd_parser.add_argument('-p','--port', action='store', type=int, default = 8000,
                                 help='Port for the server.')

    serve_cmd_parser.add_argument('-i','--ip', action='store', default = '127.0.0.1',
                                 help='IP address for the server.')

    # ls command
    ls_cmd_parser = subparsers.add_parser('ls',
                        help="List pages, drafts, or most recently edited page.")

    ls_cmd_parser.add_argument('-d', '--dirname',
        help="Directory of site root, or any place under site root.",
        action='store')

    ls_cmd_parser.add_argument('-f', '--drafts', action='store_true',
                                   help='List pages whose status is draft.')

    ls_cmd_parser.add_argument('-r', '--recent', action='store_true',
                                 help='List the most recently edited page.')


    return p