[Twisted-Python] Cisco-style hierarchial CLI

Tommi Virtanen tv at tv.debian.net
Mon Mar 22 15:33:13 EST 2004

>   Tab completion would have to be offered by whatever UI was presented, of course, and facilitated by some easily-done introspection into the Options class.

Oh, one more idea. The tab completion support should definitely be 
written so that bash and zsh programmable tab completion could be told
how to ask the app for tab completions.. E.g.

$ appname --foo -x --bar=a<TAB> path/to/dir/quux*
(cursor is on 8th char of 3rd argument, so runs e.g.
appname \
--show-tab-completions \
--tab-completion-arg=3 \
--tab-completion-cursor=8 \
-- \
--foo -x --bar=a path/to/dir/quuxthud path/do/dir/quuxbaz
which will then output something bash/zsh can parse)

>   t.p.usage.Options instances set their "subOptions" attribute when a sub-command is encountered.  I think you could exploit this fact to support nested states, by grabbing the subOptions object and asking it to parse further input.  I'm not sure how "backing up" should work, but you could probably accomplish it by keeping a stack of all the options classes that you get from the subOptions attribute.

Options have a "parent" attribute, so maintaining the stack is

More information about the Twisted-Python mailing list