@@ -83,14 +83,19 @@ def setup_subcommands():
8383 app .add_typer (mast_cli .get_app (), name = "mast" )
8484 app .add_typer (ads_cli .get_app (), name = "ads" )
8585 app .add_typer (ned_cli .get_app (), name = "ned" )
86- app .add_typer (simbad_cli .get_app (), name = "simbad" )
87- app .add_typer (splatalogue_cli .get_app (), name = "splatalogue" )
88- app .add_typer (vizier_cli .get_app (), name = "vizier" )
89- app .add_typer (heasarc_cli .get_app (), name = "heasarc" )
86+ app .add_typer (simbad_cli .get_app (), name = "simbad" , help = builtins ._ ("Query the SIMBAD astronomical database. (sim)" ))
87+ app .add_typer (simbad_cli .get_app (), name = "sim" ) # Alias for simbad
88+ app .add_typer (splatalogue_cli .get_app (), name = "splatalogue" , help = builtins ._ ("Query the Splatalogue spectral line database. (spl)" ))
89+ app .add_typer (splatalogue_cli .get_app (), name = "spl" ) # Alias for splatalogue
90+ app .add_typer (vizier_cli .get_app (), name = "vizier" , help = builtins ._ ("Query the VizieR astronomical catalog database. (viz)" ))
91+ app .add_typer (vizier_cli .get_app (), name = "viz" ) # Alias for vizier
92+ app .add_typer (heasarc_cli .get_app (), name = "heasarc" , help = builtins ._ ("Query the HEASARC database. (hea)" ))
93+ app .add_typer (heasarc_cli .get_app (), name = "hea" ) # Alias for heasarc
9094 app .add_typer (sdss_cli .get_app (), name = "sdss" )
9195 app .add_typer (eso_cli .get_app (), name = "eso" )
9296 app .add_typer (nist_cli .get_app (), name = "nist" )
93- app .add_typer (exoplanet_cli .get_app (), name = "exoplanet" )
97+ app .add_typer (exoplanet_cli .get_app (), name = "exoplanet" , help = builtins ._ ("Query the NASA Exoplanet Archive. (exo)" ))
98+ app .add_typer (exoplanet_cli .get_app (), name = "exo" ) # Alias for exoplanet
9499
95100@app .callback ()
96101def main_callback (
@@ -254,6 +259,9 @@ def custom_gettext(message):
254259 pass
255260 full_help_text = help_output_capture .getvalue ()
256261
262+ # Define aliases to filter out
263+ aliases_to_filter = ["sim" , "spl" , "viz" , "hea" , "exo" ]
264+
257265 # Remove the gaia_message from the captured help text if it's present
258266 # This is to prevent duplication if Typer's help also includes it
259267 import re
@@ -263,11 +271,31 @@ def custom_gettext(message):
263271 commands_match = re .search (r'╭─ Commands ─.*?(\n(?:│.*?\n)*)╰─.*─╯' , full_help_text , re .DOTALL )
264272 if commands_match :
265273 commands_section = commands_match .group (0 )
266- # This is a fallback in case Typer's internal help generation includes it
267- filtered_commands_section = "\n " .join ([
268- line for line in commands_section .splitlines () if "Usage:" not in line
269- ])
270- console .print (filtered_commands_section )
274+ # Filter out alias lines
275+ filtered_commands_section_lines = []
276+ for line in commands_section .splitlines ():
277+ is_alias_line = False
278+ for alias in aliases_to_filter :
279+ # Check if the line starts with the alias name followed by spaces
280+ if re .match (rf"^\s*│\s*{ re .escape (alias )} \s+" , line ):
281+ is_alias_line = True
282+ break
283+ if not is_alias_line and "Usage:" not in line :
284+ filtered_commands_section_lines .append (line )
285+
286+ # Reconstruct the commands section, ensuring the borders are kept
287+ if len (filtered_commands_section_lines ) > 1 : # Check if there's content beyond just the header/footer
288+ # Find the header and footer lines
289+ header_line = filtered_commands_section_lines [0 ]
290+ footer_line = filtered_commands_section_lines [- 1 ]
291+
292+ # Reconstruct the section with filtered content in between
293+ commands_section = header_line + "\n " + "\n " .join (filtered_commands_section_lines [1 :- 1 ]) + "\n " + footer_line
294+ else :
295+ # If only header/footer remain, just use the original filtered section
296+ commands_section = "\n " .join (filtered_commands_section_lines )
297+
298+ console .print (commands_section )
271299 else :
272300 # Fallback: if commands section not found, print full help
273301 console .print (full_help_text )
0 commit comments