INNER CODE UNIT · Python

sh_squote

torognes/vsearch · completion/scripts/gen_zsh.py:36

def sh_squote(s: str) -> str:
    """Wrap a string in single quotes, escaping embedded single quotes."""
    return "'" + s.replace("'", "'\\''") + "'"


def file_glob(extensions: list[str]) -> str:
    return "*.(" + "|".join(extensions) + ")"


def arg_action(s: spec_mod.Spec, opt: spec_mod.Option) -> str:
    """Return the `:label:action` suffix for a value-taking option, or "" for flags."""
    a = opt.arg
    if a.type == "flag":
        return ""
    if a.type == "enum":
        values = " ".join(s.enum_values(a.values))
        return f":value:({values})"
    if a.type == "file":

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…