[issue28657] cmd.Cmd.get_help() implementation can't see do_*() methods added dynamically by setattr()

2018-07-09 Thread Błażej Michalik
Błażej Michalik added the comment: It seems to me as if the current implementation forces the user to violate SRP, but I'm not going to argue about that. I don't feel equipped well enough to judge. > Could this have been done with: setattr(self.__class__, "do_" + command, &g

[issue28657] cmd.Cmd.get_help() implementation can't see do_*() methods added dynamically by setattr()

2018-07-03 Thread Błażej Michalik
Błażej Michalik added the comment: I found it. Our app had CLI that was so vast, that it didn't made sense to put all of the 'do_xyz' methods into the same class that would run the interface internals. Instead, we had a child Cmd class that had a "add_command(self, command, func, helps

[issue28657] cmd.Cmd.get_help() implementation can't see do_*() methods added dynamically by setattr()

2018-06-30 Thread Błażej Michalik
Błażej Michalik added the comment: It was nearly 2 years ago when we needed it, and we avoided the issue by overriding get_names(). I'll have to find the code in which this was used to answer your question. I guess we could've modified the class definition, however weirdly would that look

[issue28657] cmd.Cmd.get_help() implementation can't see do_*() methods added dynamically by setattr()

2018-06-30 Thread Błażej Michalik
Błażej Michalik added the comment: Yes, the proposed patch fixes all the problems that I pointed out in the last comment. -- ___ Python tracker <https://bugs.python.org/issue28

[issue28657] cmd.Cmd.get_help() implementation can't see do_*() methods added dynamically by setattr()

2018-06-17 Thread Błażej Michalik
Błażej Michalik added the comment: Sorry for not describing this one particularly well. There is nothing wrong with setattr() here, that wasn't the point. Given the code below (py3, lambdas used for brevity): # coding: utf-8 from cmd import Cmd class MyCmd(Cmd): def

[issue28657] cmd.Cmd.get_help() implementation can't see do_*() methods added dynamically by setattr()

2016-11-10 Thread Błażej Michalik
New submission from Błażej Michalik: The issue here seems to originate from the implementation of Cmd.get_names(): def get_names(self): # This method used to pull in base class attributes # at a time dir() didn't do it yet