views:

47

answers:

0

I have an command line interpreter (or "line-oriented command interpreter" in the python docs for the cmd module) for a program that I'd like to add command line utility interface to.

For example, now a session looks like this: (% for shell prompt, :) is my custom prompt)
% tasks (invokes command line interpreter)
:) clockHours Teaching_Sara_to_coregister_T1_to_T2
:) exit

In addition, I want this interface:
% tasks clockHours Teaching_Sara_to_coregister_T1_to_T2

I envision custom interpreter commands mapped onto subcommands in the command line utility. Does there exist a library for doing these together? It would be great not to have to write completion code twice, command structure code twice, etc. If not, any advice for me if I try to implement this behavior, or thoughts on how useful it might be?

Obviously I lose the advantage of simple temporary variables, which is why I was using the interpreter approach to begin with, but many of my custom interpreter commands do not rely on this behavior, or could be easily modified not to require it - it is that subset that I want command line utility subcommands for.