Skip to content

Commit c53f475

Browse files
committed
Redundant options have been merged, simplifying the command entry.
1 parent 3f5319b commit c53f475

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

astroquery_cli/modules/jpl_cli.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,21 @@ def query_horizons(ctx: typer.Context,
152152
import time
153153
start = time.perf_counter() if test else None
154154

155-
if target is None:
155+
if target is None and not any(arg in ["-h", "--help"] for arg in ctx.args):
156156
help_output_capture = StringIO()
157157
with redirect_stdout(help_output_capture):
158-
ctx.get_help()
158+
try:
159+
ctx.get_help()
160+
except SystemExit:
161+
pass
159162
full_help_text = help_output_capture.getvalue()
160163

161-
# Extract Usage and Arguments sections
162-
usage_match = re.search(r'Usage:.*?\n', full_help_text)
163-
arguments_match = re.search(r'╭─ Arguments ─.*?(\n(?:│.*?\n)*)╰─.*─╯', full_help_text, re.DOTALL)
164-
165-
if usage_match:
166-
console.print(usage_match.group(0).strip())
167-
if arguments_match:
168-
console.print(arguments_match.group(0))
164+
# Remove the "Options" section
165+
full_help_text = re.sub(r'╭─ Options ─.*?(\n(?:│.*?\n)*)╰─.*─╯', '', full_help_text, flags=re.DOTALL)
166+
# Remove the "Commands" section
167+
full_help_text = re.sub(r'╭─ Commands ─.*?(\n(?:│.*?\n)*)╰─.*─╯', '', full_help_text, flags=re.DOTALL)
169168

169+
console.print(full_help_text)
170170
raise typer.Exit()
171171

172172
console.print(_("[cyan]Querying JPL Horizons for '{target}'...[/cyan]").format(target=target))
@@ -276,15 +276,12 @@ def query_sbdb(ctx: typer.Context,
276276
ctx.get_help()
277277
full_help_text = help_output_capture.getvalue()
278278

279-
# Extract Usage and Arguments sections
280-
usage_match = re.search(r'Usage:.*?\n', full_help_text)
281-
arguments_match = re.search(r'╭─ Arguments ─.*?(\n(?:│.*?\n)*)╰─.*─╯', full_help_text, re.DOTALL)
282-
283-
if usage_match:
284-
console.print(usage_match.group(0).strip())
285-
if arguments_match:
286-
console.print(arguments_match.group(0))
279+
# Remove the "Options" section
280+
full_help_text = re.sub(r'╭─ Options ─.*?(\n(?:│.*?\n)*)╰─.*─╯', '', full_help_text, flags=re.DOTALL)
281+
# Remove the "Commands" section
282+
full_help_text = re.sub(r'╭─ Commands ─.*?(\n(?:│.*?\n)*)╰─.*─╯', '', full_help_text, flags=re.DOTALL)
287283

284+
console.print(full_help_text)
288285
raise typer.Exit()
289286

290287
console.print(_("[cyan]Querying JPL SBDB for target: '{target}'...[/cyan]").format(target=target))

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "astroquery_cli"
3-
version = "0.12.1"
3+
version = "0.12.5"
44
description = "CLI for astroquery modules with autocompletion."
55
authors = ["inoribea <inoribea@outlook.com>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)