MCPcopy Index your code
hub / github.com/pyinvoke/invoke / print_completion_script

Function print_completion_script

invoke/completion/complete.py:106–129  ·  view source on GitHub ↗
(shell: str, names: List[str])

Source from the content-addressed store, hash-verified

104
105
106def print_completion_script(shell: str, names: List[str]) -> None:
107 # Grab all .completion files in invoke/completion/. (These used to have no
108 # suffix, but surprise, that's super fragile.
109 completions = {
110 os.path.splitext(os.path.basename(x))[0]: x
111 for x in glob.glob(
112 os.path.join(
113 os.path.dirname(os.path.realpath(__file__)), "*.completion"
114 )
115 )
116 }
117 try:
118 path = completions[shell]
119 except KeyError:
120 err = 'Completion for shell "{}" not supported (options are: {}).'
121 raise ParseError(err.format(shell, ", ".join(sorted(completions))))
122 debug("Printing completion script from {}".format(path))
123 # Choose one arbitrary program name for script's own internal invocation
124 # (also used to construct completion function names when necessary)
125 binary = names[0]
126 with open(path, "r") as script:
127 print(
128 script.read().format(binary=binary, spaced_names=" ".join(names))
129 )

Callers 1

parse_coreMethod · 0.90

Calls 2

ParseErrorClass · 0.85
joinMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…