Author ngie
Recipients ngie
Date 2011-10-18.19:16:05
SpamBayes Score 6.14042e-09
Marked as misclassified No
Message-id <1318965366.62.0.48247525728.issue13214@psf.upfronthosting.co.za>
In-reply-to
Content
1. The current code in cmd.get_names does a dir on the derived class for
   cmd.Cmd object instead, which means that if I do something similar to
   the following:

class CLI(cmd.Cmd):
   def register_subcommand(self, cmd, cli_class):
       def call_cli(self):
           cli = cli_class()
           cli.cmdloop()
       setattr(self, 'do_%s' % (cmd, ), call_cli)

   it won't register the command in the completion list or help list.

2. Registering a do_EOF handler is a bit of a hack to work around
   the fact that entering in ^D on the command line prints out:

   (Cmd) *** Unknown syntax: EOF

   I can't speak to the fact that my desired behavior should be 
   enforced (basically trickle up the EOFError like so):

   def do_EOF(self, arg):
       raise EOFError

   so what I'm proposing instead is that it be filtered out by default.

Given that there's some value in allowing developers to build custom filter rules for the completions (example: certain commands can be undocumented, hidden to lower privilege users, etc), I figured it would be wise to create a custom mechanism for filtering out commands.

This could be cleaned up to use better python idioms like a generator, cache the data and have a refresh method, etc, but this is a good first start.
History
Date User Action Args
2011-10-18 19:16:06ngiesetrecipients: + ngie
2011-10-18 19:16:06ngiesetmessageid: <1318965366.62.0.48247525728.issue13214@psf.upfronthosting.co.za>
2011-10-18 19:16:06ngielinkissue13214 messages
2011-10-18 19:16:05ngiecreate