INNER CODE UNIT · Python

fish_squote

torognes/vsearch · completion/scripts/gen_fish.py:50

def fish_squote(s: str) -> str:
    """Wrap in single quotes, escaping inner single quotes."""
    return "'" + s.replace("\\", "\\\\").replace("'", "\\'") + "'"


def file_arg_flags(s: spec_mod.Spec, ftype: str | None) -> str:
    """Return the trailing flags for a file-taking option.

    Without ftype: -r (require arg, default file completion).
    With ftype:    -rfa '(__fish_complete_suffix .ext1 .ext2 ...)'
                   -r requires arg, -f suppresses default files, -a adds suffix matches.
    """
    if ftype is None:
        return "-r"
    exts = " ".join("." + e for e in s.extensions(ftype))
    return f"-rfa '(__fish_complete_suffix {exts})'"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…