@@ -57,31 +57,47 @@ def cmd2_public_attr_name(name: str) -> str:
5757
5858
5959##################################################################################################
60- # Private cmd2-specific attributes for internal use
60+ # Attribute Injection Constants
61+ #
62+ # cmd2 attaches custom attributes to various objects (functions, classes, and parsers) to
63+ # track metadata and manage command state.
64+ #
65+ # Private attributes (_cmd2_ prefix) are for internal framework logic.
66+ # Public attributes (cmd2_ prefix) are available for developer use, typically within
67+ # argparse Namespaces.
6168##################################################################################################
62- CMD_ATTR_HELP_CATEGORY = cmd2_private_attr_name ('help_category' )
63- CLASS_ATTR_DEFAULT_HELP_CATEGORY = cmd2_private_attr_name ('default_help_category' )
6469
65- # The parser for a command
70+ # --- Private Internal Attributes ---
71+
72+ # Attached to a command function; defines its argument parser
6673CMD_ATTR_ARGPARSER = cmd2_private_attr_name ('argparser' )
6774
68- # Whether or not tokens are unquoted before sending to argparse
75+ # Attached to a command function; defines its help section category
76+ CMD_ATTR_HELP_CATEGORY = cmd2_private_attr_name ('help_category' )
77+
78+ # Attached to a command function; defines whether tokens are unquoted before reaching argparse
6979CMD_ATTR_PRESERVE_QUOTES = cmd2_private_attr_name ('preserve_quotes' )
7080
71- # Subcommand attributes for the base command name and the subcommand name
81+ # Attached to a CommandSet class; defines a default help category for its member functions
82+ CMDSET_ATTR_DEFAULT_HELP_CATEGORY = cmd2_private_attr_name ('default_help_category' )
83+
84+ # Attached to a subcommand function; defines the full command path to the parent (e.g., "foo" or "foo bar")
7285SUBCMD_ATTR_COMMAND = cmd2_private_attr_name ('parent_command' )
86+
87+ # Attached to a subcommand function; defines the name of this specific subcommand (e.g., "bar")
7388SUBCMD_ATTR_NAME = cmd2_private_attr_name ('subcommand_name' )
89+
90+ # Attached to a subcommand function; specifies kwargs passed to add_parser()
7491SUBCMD_ATTR_ADD_PARSER_KWARGS = cmd2_private_attr_name ('subcommand_add_parser_kwargs' )
7592
76- # Attribute added to a parser which uniquely identifies its command set instance
93+ # Attached to an argparse parser; identifies the CommandSet instance it belongs to
7794PARSER_ATTR_COMMANDSET_ID = cmd2_private_attr_name ('command_set_id' )
7895
79- ##################################################################################################
80- # Public cmd2-specific attributes for use by developers
81- ##################################################################################################
8296
83- # Namespace attribute: Statement object that was created when parsing the command line
97+ # --- Public Developer Attributes ---
98+
99+ # Attached to an argparse Namespace; contains the Statement object created during parsing
84100NS_ATTR_STATEMENT = cmd2_public_attr_name ('statement' )
85101
86- # Namespace attribute: subcommand handler function or None if one was not set
102+ # Attached to an argparse Namespace; the function to handle the subcommand (or None)
87103NS_ATTR_SUBCMD_HANDLER = cmd2_public_attr_name ('subcmd_handler' )
0 commit comments