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])
| 300 | |
| 301 | |
| 302 | def 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 |
no test coverage detected