@@ -23,7 +23,7 @@ def get_app():
2323 _ = builtins ._
2424 app = typer .Typer (
2525 name = "nist" ,
26- help = "Query the NIST Atomic Spectra Database." ,
26+ help = builtins . _ ( "Query the NIST Atomic Spectra Database." ) ,
2727 invoke_without_command = True ,
2828 no_args_is_help = False
2929 )
@@ -34,64 +34,84 @@ def nist_callback(
3434 ctx : typer .Context ,
3535 query_string : Optional [str ] = typer .Argument (
3636 None ,
37- help = "Primary query input. Can be:\n "
38- " 1. A wavelength range (e.g., '2000 3000').\n "
39- " 2. A line name (e.g., 'Fe II', 'H I').\n "
40- "If a line name is provided without explicit --minwav/--maxwav, a broad default range will be used."
37+ help = builtins ._ ("Primary query input: wavelength range (e.g., '2000 3000') or line name (e.g., 'Fe II')." )
4138 ),
4239 minwav : Optional [float ] = typer .Option (
4340 None ,
44- help = "Explicit minimum wavelength (e.g., 2000). Overrides any wavelength range parsed from 'query_string'. "
45- "Can be combined with '--linename'."
41+ help = builtins . _ ( "Explicit minimum wavelength (e.g., 2000). Overrides any wavelength range parsed from 'query_string'. "
42+ "Can be combined with '--linename'." )
4643 ),
4744 maxwav : Optional [float ] = typer .Option (
4845 None ,
49- help = "Explicit maximum wavelength (e.g., 3000). Overrides any wavelength range parsed from 'query_string'. "
50- "Can be combined with '--linename'."
46+ help = builtins . _ ( "Explicit maximum wavelength (e.g., 3000). Overrides any wavelength range parsed from 'query_string'. "
47+ "Can be combined with '--linename'." )
5148 ),
5249 linename : Optional [str ] = typer .Option (
5350 None ,
54- help = "Explicit line name (e.g., 'Fe II', 'H I'). Overrides any line name parsed from 'query_string'. "
55- "Can be combined with explicit '--minwav' and '--maxwav' for a specific range."
51+ help = builtins . _ ( "Explicit line name (e.g., 'Fe II', 'H I'). Overrides any line name parsed from 'query_string'. "
52+ "Can be combined with explicit '--minwav' and '--maxwav' for a specific range." )
5653 ),
5754 output_file : Optional [str ] = common_output_options ["output_file" ],
5855 output_format : Optional [str ] = common_output_options ["output_format" ],
5956 max_rows_display : int = typer .Option (
60- 25 , help = "Maximum number of rows to display. Use -1 for all rows."
57+ 25 , help = builtins . _ ( "Maximum number of rows to display. Use -1 for all rows." )
6158 ),
6259 show_all_columns : bool = typer .Option (
63- False , "--show-all-cols" , help = "Show all columns in the output table."
60+ False , "--show-all-cols" , help = builtins . _ ( "Show all columns in the output table." )
6461 ),
65- test : bool = typer .Option (False , "--test" , "-t" , help = "Enable test mode and print elapsed time." ),
62+ test : bool = typer .Option (False , "--test" , "-t" , help = builtins . _ ( "Enable test mode and print elapsed time." ) ),
6663 debug_flag : bool = typer .Option ( # Renamed to avoid conflict with imported debug
6764 False ,
6865 "--debug" , # Removed -t to avoid conflict with --test
69- help = "Enable debug mode with verbose output." ,
66+ help = builtins . _ ( "Enable debug mode with verbose output." ) ,
7067 envvar = "AQC_DEBUG"
7168 ),
7269 verbose : bool = typer .Option (
7370 False ,
7471 "-v" ,
7572 "--verbose" ,
76- help = "Enable verbose output."
73+ help = builtins . _ ( "Enable verbose output." )
7774 )
7875 ):
7976 setup_debug_context (ctx , debug_flag , verbose )
8077
8178 # If no query string and no wavelength/linename options are provided, show help
8279 # This handles the case where `nist` is called without any arguments
8380 if query_string is None and minwav is None and maxwav is None and linename is None :
84- # If help is not explicitly requested, but no arguments are given, show help
81+ help_output_capture = StringIO ()
82+ with redirect_stdout (help_output_capture ):
83+ try :
84+ app (["--help" ]) # Call app with --help to get its own help
85+ except SystemExit :
86+ pass
87+ full_help_text = help_output_capture .getvalue ()
88+
89+ # Description text
90+ desc_text = (
91+ _ ("Query the NIST Atomic Spectra Database. You can query by:\n " ) +
92+ _ (" 1. Wavelength range: Provide two numbers (e.g., '2000 3000').\n " ) +
93+ _ (" 2. Line name: Provide a line name (e.g., 'Fe II', 'H I').\n " ) +
94+ _ (" If a line name is provided without explicit --minwav/--maxwav, a broad default range will be used.\n " ) +
95+ _ ("You can combine explicit --minwav/--maxwav with --linename for a specific range.\n " )
96+ )
97+
98+ # If help is not explicitly requested, show simplified help
8599 if not any (arg in ["-h" , "--help" ] for arg in ctx .args ):
86- help_output_capture = StringIO ()
87- with redirect_stdout (help_output_capture ):
88- try :
89- app (["--help" ]) # Call app with --help to get its own help
90- except SystemExit :
91- pass
92- console .print (help_output_capture .getvalue ())
100+ console .print (desc_text )
101+
102+ # Extract and print Arguments section
103+ args_match = re .search (r"(╭─ Arguments ─+╮\n.*?\n╰─+╯)" , full_help_text , flags = re .DOTALL )
104+ if args_match :
105+ console .print (args_match .group (0 ))
106+
107+ console .print (_ ("\n Use --help to see all available options." ))
108+ raise typer .Exit ()
109+ else :
110+ # If help IS explicitly requested, print full help
111+ console .print (desc_text )
112+ console .print (full_help_text )
93113 raise typer .Exit ()
94- # If help IS explicitly requested, Typer will handle it , so we just return.
114+ # Typer will handle explicit --help , so we just return if it's not handled above .
95115 return
96116
97117 _minwav = minwav
@@ -125,7 +145,7 @@ def nist_callback(
125145 _maxwav = 100000.0 # Default maximum wavelength
126146
127147 if _minwav is None or _maxwav is None :
128- console .print (f"[red]{ _ ( ' Error: Wavelength range (MINWAV and MAXWAV) must be provided either as arguments or implicitly via a line name query.' ) } [/red]" )
148+ console .print (_ ( f"[red]Error: Wavelength range (MINWAV and MAXWAV) must be provided either as arguments or implicitly via a line name query.[/red]" ) )
129149 raise typer .Exit (code = 1 )
130150
131151 if ctx .obj .get ("DEBUG" ):
0 commit comments