MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / display_command_help

Function display_command_help

keepercommander/cli.py:77–208  ·  view source on GitHub ↗
(show_enterprise=False, show_shell=False, show_legacy=False, show_nested_share_folder=True)

Source from the content-addressed store, hash-verified

75
76
77def display_command_help(show_enterprise=False, show_shell=False, show_legacy=False, show_nested_share_folder=True):
78 from .command_categories import get_command_category, get_category_order
79 from .display import bcolors
80 from colorama import Fore, Style
81 import shutil
82
83 # Build a lookup of command -> list of aliases
84 alias_lookup = {}
85 for alias, command in aliases.items():
86 if command not in alias_lookup:
87 alias_lookup[command] = []
88 alias_lookup[command].append(alias)
89 DIM = Fore.WHITE # Use white for better readability (not too bright, not too dim)
90
91 # Get terminal width
92 try:
93 terminal_width = shutil.get_terminal_size(fallback=(80, 24)).columns
94 except:
95 terminal_width = 80
96
97 def clean_description(desc):
98 """Remove trailing period from description"""
99 if desc and desc.endswith('.'):
100 return desc[:-1]
101 return desc
102
103 # Collect all commands from all sources
104 all_commands = {}
105 all_commands.update(command_info)
106 if show_enterprise:
107 all_commands.update(enterprise_command_info)
108 all_commands.update(msp_command_info)
109
110 # Group commands by category and build display info
111 categorized_commands = {}
112 for cmd, description in all_commands.items():
113 category = get_command_category(cmd)
114 if category not in categorized_commands:
115 categorized_commands[category] = []
116 categorized_commands[category].append((cmd, clean_description(description)))
117
118 # Pre-compute all command display strings and find global max width
119 # This allows alignment across all categories when terminal is wide enough
120 all_cmd_displays = [] # List of (category, cmd_display, description)
121 global_max_width = 0
122
123 # Special subcommands for certain categories
124 pam_subcommands = [
125 ('pam action', 'Execute action on the Gateway'),
126 ('pam config', 'Manage PAM Configurations'),
127 ('pam connection', 'Manage Connections'),
128 ('pam gateway', 'Manage Gateways'),
129 ('pam legacy', 'Switch to legacy PAM commands'),
130 ('pam project', 'PAM Project Import/Export'),
131 ('pam rbi', 'Manage Remote Browser Isolation'),
132 ('pam rotation', 'Manage Rotations'),
133 ('pam split', 'Split credentials from legacy PAM Machine'),
134 ('pam tunnel', 'Manage Tunnels'),

Callers 2

do_commandFunction · 0.85
executeMethod · 0.85

Calls 5

get_command_categoryFunction · 0.85
clean_descriptionFunction · 0.85
get_category_orderFunction · 0.85
updateMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected