denisidoro / navi-tldr-pages

tldr-pages for navi, an interactive cheatsheet tool for the command-line
https://github.com/denisidoro/navi
22 stars 3 forks source link

Feature Request: try detecting common arguments and set up completions (e.g. filenames). #4

Open cho-m opened 3 years ago

cho-m commented 3 years ago

It would be nice to detect arguments like '\<filename>' and automatically add support for completing files on local filesystem.

Could also be considered for main repo's navi --tldr command. Examples

denisidoro commented 3 years ago

I'm not sure I'm following. Do you want autocomplete for what kind of files? .cheat files?

cho-m commented 3 years ago

Sorry, I should have said suggestions rather than completions.

This is a feature in the interactive client TLDR++, which has some logic to detect certain common arguments used in TLDR pages (like the ones I referred to along with filtering on .<extension>).

In terms of Navi features, this would be generating $ options.

Not too sure what is best command to use though. Using {{path/to/directory}} as example, some options include:

Looking at the top 10 arguments in TLDR pages:

❯ rg -oNI --no-heading '\{\{([^}]*)\}\}' "$TEALDEER_CACHE_DIR/tldr-master/pages" | sort | uniq -c | sort -nrk1 | head -10
 371 {{path/to/file}}
 287 {{path/to/directory}}
 205 {{filename}}
 180 {{file}}
 172 {{command}}
 152 {{username}}
 121 {{package_name}}
 115 {{name}}
 108 {{path/to/file_or_directory}}
  99 {{package}}

5 of them are related to files/directories, so having the suggestion would be nice. Some of these may be new files, so need to make sure that manual input is still an available option.