Hello, everyone:

    I encouter a question when implementing a commmand line(shell).
I have implemented some commands, such as "start", "stop", "quit",
they are easily implemented by "do_start", "do_stop" and "do_quit".
there are no troubles.
     But I want to implement some commands like these "list-modules",
"show-info". There is a character "-" among the string. So I can't easily
use "do_list-modules", because the name is invalid. I attempt another
ways, add a sentense in function "cmd.onecmd":
-------------------------------------------------------
   def onecmd(self, line):
        line = line.replace("-", "_")         # I add
    ...
-------------------------------------------------------
Then, I can use "do_list_modules" to mach "list-modules" command. But in
this way, completion cannot work correctly. If I input "list-", and then
"tab",
it would not complete.

If my way is correct when encoutering commands with "-" ?
If it's correct, how can I implement completion to work correctly?



thanks,
yuanzheng.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to