Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement smart CLI autocompletion #2174

Closed
politas opened this issue Nov 4, 2017 · 7 comments
Closed

Implement smart CLI autocompletion #2174

politas opened this issue Nov 4, 2017 · 7 comments
Labels
Cmdline Issues affecting the command line Enhancement New features or functionality ★☆☆

Comments

@politas
Copy link
Member

politas commented Nov 4, 2017

It would be nice if the CLI would autocomplete commands and options and mod identifiers when the user presses tab, or show a list of things matching the text entered so far.

For example, If I type

ckan update SomeM<tab>

It could fill in SomeMod, searching the list of mods that can be updated

The challenge here is that in Mac & Linux we are actually entering a "mono" command rather than going directly calling ckan.exe. Not sure how easily we could work around that. This may not be feasible at all.

@politas politas added Cmdline Issues affecting the command line Enhancement New features or functionality ★☆☆ labels Nov 4, 2017
@HebaruSan
Copy link
Member

To see how autocompletion is implemented, take a look in /etc/bash_completion.d/ if you're on a Debian-based distro. Basically you write a shell function that parses your partial command text and returns the valid options, and then you run some variant of the complete builtin to bind it to the command. Doing it properly might require providing CKAN as a proper .deb package so we could put a file in /etc/completion.d/ (which would be cool anyway).

The problem with doing this for CKAN is that getting the list of available mods requires parsing registry.json. As noted in the comments of #2161, this file is on the order of 21 MB and growing, and takes ~2 seconds to load from an SSD. That's kind of a long time to wait for tab completion, and we would have to repeat that delay every time you tried to use autocompletion. I.e., if I do

ckan install E<tab>
ckan install Env<tab>
ckan install Environ<tab>

There would be a 2+ second delay every time I pressed tab.

I see a big potential upside in storing the mod database in a more random-access queryable format.

@politas
Copy link
Member Author

politas commented Nov 4, 2017

We do actually have a plan to reduce the size of the registry. @techman83 has done some of the work in KSP-CKAN/NetKAN-bot#58 The idea is to create different repo downloads split up according to a config file (based on KSP versions), which we can then allow the users to select in the CKAN Settings dialog. The client functionality is mostly there, I think it's just a question of setting the default repo differently and adding the other repos to the list (which is a config file in CKAN-meta)

@mathuin
Copy link
Contributor

mathuin commented Nov 4, 2017

I would note that if #2161 is implemented, this feature would be definitely possible within the repl/shell as it's all under CKAN's control.

@politas
Copy link
Member Author

politas commented Nov 5, 2017

Closing in favour of #2161, which is a better starting point.

@HebaruSan
Copy link
Member

I think this was a duplicate of #888, which even has a comment with a (slow) sample implementation.

@mathuin
Copy link
Contributor

mathuin commented Nov 9, 2017

That issue is similar to this original issue, but it is less than #2161 which would include tab completion internal to the CKAN CLI, not through bash. I'm partial to my request, of course, but I do think having this inside CKAN is superior because it allows all shell users to benefit, whether Windows Powershell or Linux tcsh (ptui) or anything in between.

@HebaruSan
Copy link
Member

Agreed, #2161 is not a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cmdline Issues affecting the command line Enhancement New features or functionality ★☆☆
Projects
None yet
Development

No branches or pull requests

3 participants