twolfson / commander-completion

Shell completion for commander.js
The Unlicense
26 stars 4 forks source link

Fallback to default bash completion (or filesystem completion) #10

Open MichalCz opened 1 year ago

MichalCz commented 1 year ago

Hi,

We use commander in scramjetorg/transform-hub in our CLI. We love your plugin, but we'd like our users to be able to complete files with <tab> <tab>. Bash has quite nice completion for this, so would this be possible to fallback to simple file completions?

Any ideas how to achieve this?

twolfson commented 1 year ago

I'm sadly pretty out of this headspace =/ I'm not sure if there's a way to fallback for a subset once a completion is introduced

I feel like I've seen this with git-extras bash completion (e.g. git delete-branch <tab> in a non-git folder lists files (git delete-br<tab> completes to git delete-branch)) so maybe worth exploring there?

https://github.com/tj/git-extras/blob/7.0.0/etc/bash_completion.sh

Another option is using fs.readdir as part of your completion logic, https://nodejs.org/api/fs.html#fsreaddirpath-options-callback

I'll leave this issue open as an "enhancement" feature