def main(self, args=None, prog_name=None, complete_var=None,<EOL>standalone_mode=True, **extra):
<EOL>if not PY2:<EOL><INDENT>_verify_python3_env()<EOL><DEDENT>else:<EOL><INDENT>_check_for_unicode_literals()<EOL><DEDENT>if args is None:<EOL><INDENT>args = get_os_args()<EOL><DEDENT>else:<EOL><INDENT>args = list(args)<EOL><DEDENT>if prog_name is None:<EOL><INDENT>prog_name = make_str(os.path.basename(<EOL>sys.argv and sys.argv[<NUM_LIT:0>] or __file__))<EOL><DEDENT>_bashcomplete(self, prog_name, complete_var)<EOL>try:<EOL><INDENT>try:<EOL><INDENT>with self.make_context(prog_name, args, **extra) as ctx:<EOL><INDENT>rv = self.invoke(ctx)<EOL>if not standalone_mode:<EOL><INDENT>return rv<EOL><DEDENT>ctx.exit()<EOL><DEDENT><DEDENT>except (EOFError, KeyboardInterrupt):<EOL><INDENT>echo(file=sys.stderr)<EOL>raise Abort()<EOL><DEDENT>except ClickException as e:<EOL><INDENT>if not standalone_mode:<EOL><INDENT>raise<EOL><DEDENT>e.show()<EOL>sys.exit(e.exit_code)<EOL><DEDENT>except IOError as e:<EOL><INDENT>if e.errno == errno.EPIPE:<EOL><INDENT>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT>except Abort:<EOL><INDENT>if not standalone_mode:<EOL><INDENT>raise<EOL><DEDENT>echo('<STR_LIT>', file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>
This is the way to invoke a script with all the bells and
        whistles as a command line application.  This will always terminate
        the application after a call.  If this is not wanted, ``SystemExit``
        needs to be caught.

        This method is also available by directly calling the instance of
        a :class:`Command`.

        .. versionadded:: 3.0
           Added the `standalone_mode` flag to control the standalone mode.

        :param args: the arguments that should be used for parsing.  If not
                     provided, ``sys.argv[1:]`` is used.
        :param prog_name: the program name that should be used.  By default
                          the program name is constructed by taking the file
                          name from ``sys.argv[0]``.
        :param complete_var: the environment variable that controls the
                             bash completion support.  The default is
                             ``"_<prog_name>_COMPLETE"`` with prog name in
                             uppercase.
        :param standalone_mode: the default behavior is to invoke the script
                                in standalone mode.  Click will then
                                handle exceptions and convert them into
                                error messages and the function will never
                                return but shut down the interpreter.  If
                                this is set to `False` they will be
                                propagated to the caller and the return
                                value of this function is the return value
                                of :meth:`invoke`.
        :param extra: extra keyword arguments are forwarded to the context
                      constructor.  See :class:`Context` for more information.