from typing import Any
import re


def parse(optionDescription: str) -> tuple[str, str, str, Any, str]:
	"""Parse an option help text, adapted from docopt."""
	short, long, argcount, value = "", "", 0, False
	options, _, description = optionDescription.strip().partition("  ")
	options = options.replace(",", " ").replace("=", " ")
	for section in options.split():
		if section.startswith("--"):
			long = section
		elif section.startswith("-"):
			short = section
		else:
			argcount = 1
	if argcount > 0:
		matched = re.findall(r"\[default: (.*)\]", description, flags=re.I)
		value = matched[0] if matched else ""
	return (short, long, str(argcount), value, description.strip())