Skip to content

Support path autocompletion for Path-typed Click options (via textual-autocomplete) #125

Description

@chourroutm

Problem

When a Click command has an option/argument typed as click.Path(...), Trogon renders it as a plain Input widget with no filesystem awareness. Users have to type the full path from memory (or tab out to a terminal to check), which is a significant UX gap for any CLI that deals with files or directories.

Proposed solution

textual-autocomplete (same author, MIT licensed) ships a ready-made PathAutoComplete widget that attaches live, incremental filesystem completion to any Input:

from textual_autocomplete import PathAutoComplete

PathAutoComplete(target=my_input, path=Path.cwd())

It would be great if Trogon detected click.Path parameter types (including exists=True, file_okay/dir_okay flags) and automatically attached a PathAutoComplete to the generated Input for that field, seeded from the relevant root (cwd, or a configurable default).

Why this matters

Right now, generating a form from a CLI that takes file/directory arguments produces a strictly worse experience than just running the command manually with shell tab-completion. Wiring in PathAutoComplete would close that gap and make Trogon-generated forms competitive with a real shell for path-heavy commands.

Notes

  • Confirmed in the current release (0.6.0) that textual-autocomplete is not a dependency and there's no autocomplete logic in the
    form-generation code — this looks like an open gap rather than something misconfigured on my end.
  • Happy to help prototype this if there's interest in a PR — I have a small standalone example wiring PathAutoComplete into a Textual Input that could serve as a starting point for the integration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions