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

TODO: Add auto-complete support for the Console driver. #22

Closed
josher19 opened this issue Mar 22, 2013 · 6 comments
Closed

TODO: Add auto-complete support for the Console driver. #22

josher19 opened this issue Mar 22, 2013 · 6 comments

Comments

@josher19
Copy link

I can help with the auto-complete. I've landed commits to improve the completer docs for Node and the REPL for LiveScript (a nice fork of CoffeeScript).

Are you just looking for auto-completing most of the commands listed under "help" when running

% bin/prey -d console

So, for example,

prey> wa[TAB]

would expand to

prey> watch 

and

prey> watch g[TAB]

would expand to

prey> watch geofence

and so on.

@ghost
Copy link

ghost commented Mar 22, 2013

Good idea! Currently we are working on a full refactoring of both the configuration and the Prey agent console layers. Those are using a modified version of operetta and commander. What library or steps do you have in mind to achieve autocompletion?

@josher19
Copy link
Author

readline.createInterface can have a completer sent as the third argument.

One way using the existing (prey v0.9.2) code would be to have it use all output from the help module which starts with a tab or space.

I'll send a pull request with proposed changes.

josher19 added a commit to josher19/prey-node-client that referenced this issue Mar 23, 2013
Grab console completions from help.js
Fixes prey#22
@josher19
Copy link
Author

Originally coded against v0.9.2 but applied it to the conf/refactor branch for this pull request.

Does not directly use operetta or commander so should work on any branch.

% bin/prey -d console

Can get some more of the gory details by doing:

% bin/prey -D -d console

but you can hide those in production by setting

var debug = false;

or deleting the lines starting with if (debug)

PS: while you are refactoring, you might consider changing shortcuts of --debug (-D) and --driver (-d)
because of old windows case-sensitivity issues.

Cheers,
->> Joshua S. Weinstein <<-

@josher19
Copy link
Author

This solution uses help.show and uses any line that begins with a space or tab and a letter as possible completions (thus skipping lines that begin with " >"). So if you change the help command it will automatically change the completions.

If you change the "config" help to be like:

prey> help config
Sets or gets a config setting.
config [update|read] [key]

Sub-commands:
    update
    read

Possible keys:
    driver
    host
    api_key
    device_key
    campfire
    imgur
    ...

then doing

prey> config [TAB]

will have these completions:

update
read
driver
host
api_key
device_key
campfire
imgur

More about the readline completer in the node docs:
http://nodejs.org/api/readline.html#readline_readline_createinterface_options

@josher19
Copy link
Author

If you also want command line auto-completion of the argument list in bash for Linux, you can take a look at:
https://github.com/josher19/complete

Not sure how compatible with operetta it is as it requires optimist.

@tomas
Copy link
Contributor

tomas commented Oct 21, 2013

Not really sure at which point this was merged but it's already on master. Thanks @josher19!

@tomas tomas closed this as completed Oct 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants