INNER CODE UNIT · Python

file_arg_flags

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

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})'"


def option_flags(s: spec_mod.Spec, opt: spec_mod.Option) -> str:
    """Return the per-option fish complete flags excluding -c/-n/-l/-s/-d."""
    a = opt.arg
    if a.type == "flag":
        return "-f"  # no arg, no file completion

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…