carapace-sh / carapace

command argument completion generator for spf13/cobra
https://carapace.sh
Apache License 2.0
290 stars 8 forks source link

traverse: collect context information about args #922

Open rsteube opened 9 months ago

rsteube commented 9 months ago

Request

Since traverse already iterates over the arguments and identifies them this should be stored and optionally returned.

Proposed solution

Provide an array of context information:

Anything else?

gh issue --repo rsteube/carapace list --label enhancement --state open --web

Could be visualized like:

gh # GitHub CLI
issue # Manage issues
  --repo rsteube/carapace # Select another repository using the `[HOST/]OWNER/REPO` format
list #  List issues in a repository
  --label enhancement # Filter by label
  --state open # Filter by state: {open|closed|all}
  --web # List issues in the web browser
rsteube commented 9 months ago

Flag chains could pose an issue. Might be more helpful to destructure the arguments (and even prefer the longhand for flags?).

ls -lha /tmp
exa # a modern replacement for ls
  -l # display extended file metadata as a table
  -h # add a header row to each column
  -a # show hidden and 'dot' files
  /tmp