#! /usr/bin/env python

import argparse

from commands import fixup


def main():

    parser = argparse.ArgumentParser(
        prog='git fixup',
        version='git-fixup 0.4.0',
        description=fixup.__doc__,
        epilog='for more detail, use: git help fixup'
    )

    # <commit>
    parser.add_argument(
        'commit',
        help='the commit to fixup into (default: HEAD)',
        nargs='?',
        default='HEAD',
        metavar='<commit>'
    )

    # -a|--all
    parser.add_argument(
        '-a',
        '--all',
        help='stage all files',
        action='store_const',
        const=fixup.ALL,
        dest='add_mode'
    )

    # -u|--update
    parser.add_argument(
        '-u',
        '--update',
        help='stage tracked files only',
        action='store_const',
        const=fixup.UPDATE,
        dest='add_mode'
    )

    # -b|--body
    parser.add_argument(
        '-b',
        '--body',
        help='the message body to use in the fixup commit',
        metavar='<message>'
    )

    fixup.fixup(**vars(parser.parse_args()))

if __name__ == '__main__':
    main()
