(shell=None, prog_name=None, env_name=None, extra_env=None)
return template.render(prog_name=prog_name, complete_var=env_name, extra_env=extra_env)
Returns the completion code to be evaluated by the shell

    Parameters
    ----------
    shell : Shell
        The shell type (Default value = None)
    prog_name : str
        The program name on the command line (Default value = None)
    env_name : str
        The environment variable used to control the completion (Default value = None)
    extra_env : dict
        Some extra environment variables to be added to the generated code (Default value = None)

    Returns
    -------
    str
        The code to be evaluated by the shell
Returns the completion code to be evaluated by the shell
Returns the completion code to be evaluated by the shell
def get_code(shell=None, prog_name=None, env_name=None, extra_env=None):
    """Returns the completion code to be evaluated by the shell

    Parameters
    ----------
    shell : Shell
        The shell type (Default value = None)
    prog_name : str
        The program name on the command line (Default value = None)
    env_name : str
        The environment variable used to control the completion (Default value = None)
    extra_env : dict
        Some extra environment variables to be added to the generated code (Default value = None)

    Returns
    -------
    str
        The code to be evaluated by the shell
    """
    from jinja2 import Environment, FileSystemLoader
    if shell in [None, 'auto']:
        shell = get_auto_shell()
    if not isinstance(shell, Shell):
        shell = Shell[shell]
    prog_name = prog_name or click.get_current_context().find_root().info_name
    env_name = env_name or '_%s_COMPLETE' % prog_name.upper().replace('-', '_')
    extra_env = extra_env if extra_env else {}
    env = Environment(loader=FileSystemLoader(os.path.dirname(__file__)))

    click_ver = distutils.version.StrictVersion(click.__version__)
    click8_ver = distutils.version.StrictVersion('8.0.0')
    if click_ver >= click8_ver:
        template_name = '%s-click8.j2'
    else:
        template_name = '%s.j2'
    template = env.get_template(template_name % shell.name)

    return template.render(prog_name=prog_name, complete_var=env_name, extra_env=extra_env)
def get_code ( shell = None , prog_name = None , env_name = None , extra_env = None ) : from jinja2 import Environment , FileSystemLoader if shell in [ None , 'auto' ] : shell = get_auto_shell ( ) if not isinstance ( shell , Shell ) : shell = Shell [ shell ] prog_name = prog_name or click . get_current_context ( ) . find_root ( ) . info_name env_name = env_name or '_%s_COMPLETE' % prog_name . upper ( ) . replace ( '-' , '_' ) extra_env = extra_env if extra_env else { } env = Environment ( loader = FileSystemLoader ( os . path . dirname ( __file__ ) ) ) click_ver = distutils . version . StrictVersion ( click . __version__ ) click8_ver = distutils . version . StrictVersion ( '8.0.0' ) if click_ver >= click8_ver : template_name = '%s-click8.j2' else : template_name = '%s.j2' template = env . get_template ( template_name % shell . name ) return template . render ( prog_name = prog_name , complete_var = env_name , extra_env = extra_env )