Command.args() has no command line visibility
It would be useful to have visibility into the command line being completed in Command.args().
For instance, if you wanted to do bash-style path completion, you could simply:
from ishell.console import Console
from ishell.command import Command
import glob
class ExampleCommand(Command):
def args(self, line):
line_without_command_name = ''.join(line.split()[1:])
return glob.glob(line_without_command_name + '*')
def run(self, line):
print "This is an example command."
example = ExampleCommand('example', dynamic_args=True)
console = Console()
console.addChild(example)
You can get the current readline buffer with readline.get_line_buffer(), it'll probably return the line you want.
The only problem in adding the line there is breaking the api since the Command will call args function with an additional argument. We can do this but probably version it with a new major version like 1.0.0 and put a warning in 0.1.5 if we detect only one arg.
Thank you for the workaround! Yes, readline.get_line_buffer() appears to provide the right line.