Turns decorated functions into command line args

    Finds the main_command and all commands and generates command line args
    from these.

def commandify(use_argcomplete=False, exit=True, *args, **kwargs):
    '''Turns decorated functions into command line args

    Finds the main_command and all commands and generates command line args
    from these.'''
    parser = CommandifyArgumentParser(*args, **kwargs)
    parser.setup_arguments()
    if use_argcomplete:
        try:
            import argcomplete
        except ImportError:
            print('argcomplete not installed, please install it.')
            parser.exit(status=2)
        # Must happen between setup_arguments() and parse_args().
        argcomplete.autocomplete(parser)
    args = parser.parse_args()
    if exit:
        parser.dispatch_commands()
        parser.exit(0)
    else:
        return parser.dispatch_commands()