Skip to content

Commit 30f4d42

Browse files
committed
fixed bugs
1 parent 77e665c commit 30f4d42

File tree

8 files changed

+78
-22
lines changed

8 files changed

+78
-22
lines changed

astroquery_cli/main.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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()
96101
def 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)

astroquery_cli/modules/ads_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_app():
2323
_ = builtins._
2424
app = typer.Typer(
2525
name="ads",
26-
help=builtins._("Query the NASA Astrophysics Data System (ADS)."),
26+
help=builtins._("Query the NASA Astrophysics Data System"),
2727
invoke_without_command=True, # Add this to allow callback to run without subcommand
2828
no_args_is_help=False # Set to False for custom handling
2929
)

astroquery_cli/modules/eso_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_app():
2323
_ = builtins._
2424
app = typer.Typer(
2525
name="eso",
26-
help=builtins._("Query the European Southern Observatory (ESO) archive."),
26+
help=builtins._("Query the European Southern Observatory archive."),
2727
invoke_without_command=True,
2828
no_args_is_help=False
2929
)

astroquery_cli/modules/irsa_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_app():
2929
_ = builtins._
3030
app = typer.Typer(
3131
name="irsa",
32-
help=builtins._("Query NASA/IPAC Infrared Science Archive (IRSA)."),
32+
help=builtins._("Query NASA/IPAC Infrared Science Archive"),
3333
invoke_without_command=True, # Add this to allow callback to run without subcommand
3434
no_args_is_help=False # Set to False for custom handling
3535
)

astroquery_cli/modules/jpl_cli.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,40 @@ def jpl_callback(
6060
except SystemExit:
6161
pass
6262
full_help_text = help_output_capture.getvalue()
63+
64+
# Define aliases to filter out
65+
aliases_to_filter = ["h", "s"]
66+
6367
commands_match = re.search(r'╭─ Commands ─.*?(\n(?:│.*?\n)*)╰─.*─╯', full_help_text, re.DOTALL)
6468
if commands_match:
6569
commands_section = commands_match.group(0)
66-
filtered_commands_section = "\n".join([
67-
line for line in commands_section.splitlines() if "Usage:" not in line
68-
])
69-
console.print(filtered_commands_section)
70+
# Filter out alias lines
71+
filtered_commands_section_lines = []
72+
for line in commands_section.splitlines():
73+
is_alias_line = False
74+
for alias in aliases_to_filter:
75+
# Check if the line starts with the alias name followed by spaces
76+
if re.match(rf"^\s*│\s*{re.escape(alias)}\s+", line):
77+
is_alias_line = True
78+
break
79+
if not is_alias_line and "Usage:" not in line:
80+
filtered_commands_section_lines.append(line)
81+
82+
# Reconstruct the commands section, ensuring the borders are kept
83+
if len(filtered_commands_section_lines) > 1: # Check if there's content beyond just the header/footer
84+
# Find the header and footer lines
85+
header_line = filtered_commands_section_lines[0]
86+
footer_line = filtered_commands_section_lines[-1]
87+
88+
# Reconstruct the section with filtered content in between
89+
commands_section = header_line + "\n" + "\n".join(filtered_commands_section_lines[1:-1]) + "\n" + footer_line
90+
else:
91+
# If only header/footer remain, just use the original filtered section
92+
commands_section = "\n".join(filtered_commands_section_lines)
93+
94+
console.print(commands_section)
7095
else:
96+
# Fallback: if commands section not found, print full help
7197
console.print(full_help_text)
7298
raise typer.Exit()
7399

@@ -105,7 +131,8 @@ def get_default_quantities_ephem(ctx: typer.Context,):
105131
_ = i18n.get_translator(lang)
106132
return "1,2,4,8,9,10,12,13,14,19,20,21,23,24,31"
107133

108-
@app.command(name="horizons", help=builtins._("Query ephemerides, orbital elements, or vectors for a target object."))
134+
@app.command(name="horizons", help=builtins._("Query ephemerides, orbital elements, or vectors for a target object. (h)"))
135+
@app.command(name="h", help=builtins._("Alias for horizons."))
109136
@global_keyboard_interrupt_handler
110137
def query_horizons(ctx: typer.Context,
111138
target: Optional[str] = typer.Argument(None, help=builtins._("Object ID (e.g., 'Mars', 'Ceres', '2000NM', '@10'). Use '@' prefix for spacecraft ID.")),
@@ -247,7 +274,7 @@ def query_horizons(ctx: typer.Context,
247274

248275
sbdb_app = typer.Typer(
249276
name="sbdb",
250-
help=builtins._("Query JPL Small-Body Database (SBDB)."),
277+
help=builtins._("Query JPL Small-Body Database (SBDB). (s)"),
251278
no_args_is_help=False
252279
)
253280

@@ -431,4 +458,5 @@ def default(self, obj):
431458
raise typer.Exit()
432459

433460
app.add_typer(sbdb_app, name="sbdb")
461+
app.add_typer(sbdb_app, name="s") # Alias for sbdb
434462
return app

astroquery_cli/modules/mast_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_app():
2323
_ = builtins._
2424
app = typer.Typer(
2525
name="mast",
26-
help=builtins._("Query the Mikulski Archive for Space Telescopes (MAST)."),
26+
help=builtins._("Query the Mikulski Archive for Space Telescopes"),
2727
invoke_without_command=True, # Add this to allow callback to run without subcommand
2828
no_args_is_help=False # Set to False for custom handling
2929
)

astroquery_cli/modules/ned_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_app():
2323
_ = builtins._
2424
app = typer.Typer(
2525
name="ned",
26-
help=builtins._("Query the NASA/IPAC Extragalactic Database (NED)."),
26+
help=builtins._("Query the NASA/IPAC Extragalactic Database"),
2727
invoke_without_command=True, # Add this to allow callback to run without subcommand
2828
no_args_is_help=False # Set to False for custom handling
2929
)

astroquery_cli/modules/sdss_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def get_app():
2424
app = typer.Typer(
2525
name="sdss",
2626
help=builtins._(
27-
"Query the Sloan Digital Sky Survey (SDSS) database.\n\n"
27+
"Query the Sloan Digital Sky Survey database.\n\n"
2828
"Perform a query on SDSS. You must provide parameters for exactly one of the following query types:\n\n"
2929
" 1. Cone Search:\n"
3030
" --ra <RA> --dec <DEC> --radius <RADIUS>\n"

0 commit comments

Comments
 (0)