piotrmurach/tty-option

CLI Completion Scripts

Closed this issue · 1 comments

Describe the problem

One thing I've been doing lately with my (unfortunately private, so I've no examples) CLI scripts is to provide a file that lets the user bootstrap tab-completion automatically, either by copying it into a shell configuration file like ~/.bashrc or copying the file entirely, like completion/_foo.zsh, into a place where it can be automatically picked up.

I think it would be useful to be able to automatically generate these from TTY::Option, even though some of the features wouldn't be translatable into every shell.

How would the new feature work?

It doesn't quite make sense to generate this during normal runtime, but since you already have #parse, perhaps we could add #to_completion(shell = :bash) or something.

Drawbacks

Mostly that it could be argued this is out of scope for the gem, and a lot of work to research and support a bunch of different shells. At a glance, the gem already looks quite powerful and I'm going to actually try it out on my next script.

Hi Michael 👋

Thank you for taking interest in tty-option and sharing your idea for generating completion scripts.

I like the idea but equally, I don't have the investment time to work on this. I have many other projects and ideas that I wish to do and this has never been in scope for this gem. I can see the utility in having the ability to automatically generate completion scripts. But my worry is the maintenance of this feature would be significant, given the possible shells and allowing configuration of what should and shouldn't be completed.

Now, if you have time and wish to see this functionality please create a proof of concept and share it. We can then collaborate and see what's the best way to handle it.

Given the above, I will close this suggestion.