@@ -440,7 +440,6 @@ def _get_extension_suppressions(mod_loaders):
440440 # Display help directly from cached data without loading modules
441441 self ._display_cached_help (help_index )
442442 # Raise SystemExit to stop execution (similar to how --help normally works)
443- import sys
444443 sys .exit (0 )
445444
446445 if use_command_index :
@@ -530,18 +529,48 @@ def _display_cached_help(self, help_index):
530529 # Show welcome message
531530 print (WELCOME_MESSAGE )
532531
533- # Display subgroups from cached data
534- if help_index :
535- print ("Subgroups:" )
536- # Sort and display in the same format as normal help
537- max_name_len = max (len (name ) for name in help_index .keys ())
538- for name in sorted (help_index .keys ()):
539- summary = help_index [name ]
540- padding = ' ' * (max_name_len - len (name ))
541- print (f" { name } { padding } : { summary } " )
532+ # Show Group header (to match normal help output)
533+ print ("\n Group" )
534+ print (" az" )
535+
536+ # Separate groups and commands
537+ groups = help_index .get ('groups' , {})
538+ commands = help_index .get ('commands' , {})
539+
540+ # Calculate max name length including tags for proper alignment
541+ def _get_display_len (name , tags ):
542+ tag_len = len (tags ) + 1 if tags else 0 # +1 for space before tags
543+ return len (name ) + tag_len
544+
545+ max_len = 0
546+ if groups :
547+ max_len = max (max_len , max (_get_display_len (name , item .get ('tags' , '' )) for name , item in groups .items ()))
548+ if commands :
549+ max_len = max (max_len , max (_get_display_len (name , item .get ('tags' , '' )) for name , item in commands .items ()))
550+
551+ # Display subgroups
552+ if groups :
553+ print ("\n Subgroups:" )
554+ for name in sorted (groups .keys ()):
555+ item = groups [name ]
556+ tags = item .get ('tags' , '' )
557+ summary = item .get ('summary' , '' )
558+ name_with_tags = f"{ name } { tags } " if tags else name
559+ padding = ' ' * (max_len - _get_display_len (name , tags ))
560+ print (f" { name_with_tags } { padding } : { summary } " )
561+
562+ # Display commands
563+ if commands :
564+ print ("\n Commands:" )
565+ for name in sorted (commands .keys ()):
566+ item = commands [name ]
567+ tags = item .get ('tags' , '' )
568+ summary = item .get ('summary' , '' )
569+ name_with_tags = f"{ name } { tags } " if tags else name
570+ padding = ' ' * (max_len - _get_display_len (name , tags ))
571+ print (f" { name_with_tags } { padding } : { summary } " )
542572
543573 print ("\n To search AI knowledge base for examples, use: az find \" az \" " )
544- print ("\n For more specific examples, use: az find \" az <command>\" " )
545574
546575 # Show update notification
547576 from azure .cli .core .util import show_updates_available
@@ -563,17 +592,40 @@ def _cache_help_index(self, command_index):
563592 help_file = CliGroupHelpFile (self .cli_ctx .invocation .help , '' , subparser )
564593 help_file .load (subparser )
565594
566- # Extract summaries from help file's children
567- help_index_data = {}
595+ # Helper to build tag string for an item
596+ def _get_tags (item ):
597+ tags = []
598+ if hasattr (item , 'deprecate_info' ) and item .deprecate_info :
599+ tags .append (str (item .deprecate_info .tag ))
600+ if hasattr (item , 'preview_info' ) and item .preview_info :
601+ tags .append (str (item .preview_info .tag ))
602+ if hasattr (item , 'experimental_info' ) and item .experimental_info :
603+ tags .append (str (item .experimental_info .tag ))
604+ return ' ' .join (tags )
605+
606+ # Separate groups and commands
607+ groups = {}
608+ commands = {}
609+
568610 for child in help_file .children :
569611 if hasattr (child , 'name' ) and hasattr (child , 'short_summary' ):
570- if ' ' not in child .name : # Only top-level commands
571- help_index_data [child .name ] = child .short_summary
612+ if ' ' not in child .name : # Only top-level items
613+ tags = _get_tags (child )
614+ item_data = {
615+ 'summary' : child .short_summary ,
616+ 'tags' : tags
617+ }
618+ # Check if it's a group or command
619+ if child .type == 'group' :
620+ groups [child .name ] = item_data
621+ else :
622+ commands [child .name ] = item_data
572623
573624 # Store in the command index
574- if help_index_data :
625+ help_index_data = {'groups' : groups , 'commands' : commands }
626+ if groups or commands :
575627 command_index .INDEX [command_index ._HELP_INDEX ] = help_index_data
576- logger .debug ("Cached %d help entries " , len (help_index_data ))
628+ logger .debug ("Cached %d groups and %d commands " , len (groups ), len ( commands ))
577629 except Exception as ex : # pylint: disable=broad-except
578630 logger .debug ("Failed to cache help data: %s" , ex )
579631
0 commit comments