MCPcopy
hub / github.com/pallets/click / join_options

Function join_options

src/click/formatting.py:302–320  ·  view source on GitHub ↗

Given a list of option strings this joins them in the most appropriate way and returns them in the form ``(formatted_string, any_prefix_is_slash)`` where the second item in the tuple is a flag that indicates if any of the option prefixes was a slash.

(options: cabc.Iterable[str])

Source from the content-addressed store, hash-verified

300
301
302def join_options(options: cabc.Iterable[str]) -> tuple[str, bool]:
303 """Given a list of option strings this joins them in the most appropriate
304 way and returns them in the form ``(formatted_string,
305 any_prefix_is_slash)`` where the second item in the tuple is a flag that
306 indicates if any of the option prefixes was a slash.
307 """
308 rv = []
309 any_prefix_is_slash = False
310
311 for opt in options:
312 prefix = _split_opt(opt)[0]
313
314 if prefix == "/":
315 any_prefix_is_slash = True
316
317 rv.append((len(prefix), opt))
318
319 rv.sort(key=lambda x: x[0])
320 return ", ".join(x[1] for x in rv), any_prefix_is_slash

Callers 1

_write_optsMethod · 0.85

Calls 1

_split_optFunction · 0.85

Tested by

no test coverage detected