Skip to content

shortcuts should not be a publicly accessible attribute #683

Closed
@kotfu

Description

@kotfu

We have some inconsistencies in our api and our documentation. In 0.9.12 we added shortcuts as an optional argument to __init__(), and changed the initialization code associated with these shortcuts. This created the following issues:

  • the changelog said nothing about disabling the .shortcuts attribute. Prior to 0.9.12 you could modify that attribute to change the shortcuts. After 0.9.12, the only way to change the shortcuts is to pass them to __init__()
  • What's the point of the shortcuts attribute on a cmd object if the caller has to pass it in, and it's read only? When cmd2 code needs it, can get it from the statement_parser, and code that instantiates cmd2.Cmd() or a subclass thereof already know it because they passed it in.
  • the docstring for the init method says you should pass shortcuts as a dictionary, and then the initialization code processes those and stores a tuple in the shortcuts attribute (which has a property to access it). It seems inconsistent to pass a dictionary and access a tuple.
  • The DEFAULT_SHORTCUTS variable should really be in constants.py, not cmd2.py

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions