+
+ # start incrementing substrings
+ for position in range(1, len(command_name) + 1):
+
+ # we've found our shortest possible abbreviation
+ candidate = mudpy.misc.find_command(
+ command_name[:position])
+ try:
+ if candidate.subkey == command_name:
+ break
+ except AttributeError:
+ pass
+
+ # use square brackets to indicate optional part of command name
+ if position < len(command_name):
+ abbrev = "%s[%s]" % (
+ command_name[:position], command_name[position:])
+ else:
+ abbrev = command_name
+
+ # supply a useful default if the short description is missing
+ description = command.get(
+ "description", "(no short description provided)")
+
+ # administrative command names are in red, others in green