I have a PHP command line script which kicks off a job to a job server, with the job name being an argument. The job names are namespaced, such as Foo:Bar_Baz_JobName. Is there a way I could implement auto-completion, like how typing the first few letters of a filename and pressing tab bash completes the file name for you. I know it can be done, because tab-completion works on ubuntu with apt-get, I just don't know if it can be done in PHP.
+4
A:
Autocompletion is done using the GNU readline library, which apparently is accessible from PHP. Specifically, look at readline_completion_function
. Usage is fairly simple; you call readline_completion_function
with one argument, a callback function that handles the completion. The callback function takes the first few letters (basically, whatever you type before pressing TAB) as input and should return an array of possible matches.
David Zaslavsky
2010-07-09 19:17:20
A:
You can try using readline, more specifically, the readline_completion_function
function.
Ionuț G. Stan
2010-07-09 19:17:59