Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method to customize the help message of a command #1195

Closed
wants to merge 2 commits into from

Conversation

vincent-lg
Copy link
Contributor

Brief overview of PR changes/additions

This pull request adds a method 'get_help' to all commands. By default, this method simply returns the command's docstring, but one can create a command that still uses 'auto_help', but displays a customizable message.

Motivation for adding to Evennia

The 'auto_help' system is great, but it's either on or off. This pull request offers an alternative: a way to customize the help of commands without rejecting their docstring.

Example: I have a set of commands with sub-commands (separated by spaces), like "room" (master command), "room list" (see the list of rooms in the area), "room name" (change the name of the room) and so on. When one enters "help room", he/she should see the other sub-commands available. Updating the "room" docstring could increase the potential for errors. But the help system could auto-generate help for this command (and sub-commands) very easily.

though, and even customize it depending on the caller.

Args:
self: the command itself.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the Evennia style guide here.

  • self should not be included as an argument
  • All arguments should list its type within parentheses. it comes to Evennia entities, I usually use Object rather than ObjectDB for clarity, so for example caller (Object or Player). The cmdset should have CmdSet as type.
  • Since the return is not implicit, the Returns block should be listed, something like
    Returns:
        docstring (str): The help text to return for this command. 
    

@Griatch
Copy link
Member

Griatch commented Feb 5, 2017

This looks like a good idea. See my note about the Evennia policy on docstring syntax.

@Griatch
Copy link
Member

Griatch commented Feb 7, 2017

Merged with a rebase.

@Griatch Griatch closed this Feb 7, 2017
@vincent-lg vincent-lg deleted the improve_help branch February 10, 2017 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants