44
55from typing import Annotated , get_args
66
7+ from click import Choice
78from typer import Context , Option , Typer
89from typer_config import use_config
910
2122 WriteKwargs ,
2223)
2324from janus_core .cli .utils import yaml_converter_callback
25+ from janus_core .helpers .janus_types import EoSNames
2426
2527app = Typer ()
2628
@@ -35,7 +37,11 @@ def eos(
3537 max_volume : Annotated [float , Option (help = "Maximum volume scale factor." )] = 1.05 ,
3638 n_volumes : Annotated [int , Option (help = "Number of volumes." )] = 7 ,
3739 eos_type : Annotated [
38- str , Option (help = "Type of fit for equation of state." )
40+ str ,
41+ Option (
42+ click_type = Choice (get_args (EoSNames )),
43+ help = "Type of fit for equation of state." ,
44+ ),
3945 ] = "birchmurnaghan" ,
4046 minimize : Annotated [
4147 bool , Option (help = "Whether to minimize initial structure before calculations." )
@@ -140,7 +146,6 @@ def eos(
140146 set_read_kwargs_index ,
141147 start_summary ,
142148 )
143- from janus_core .helpers .janus_types import EoSNames
144149
145150 # Check options from configuration file are all valid
146151 check_config (ctx )
@@ -149,9 +154,6 @@ def eos(
149154 [read_kwargs , calc_kwargs , minimize_kwargs , write_kwargs ]
150155 )
151156
152- if eos_type not in get_args (EoSNames ):
153- raise ValueError (f"Fit type must be one of: { get_args (EoSNames )} " )
154-
155157 # Set initial config
156158 all_kwargs = {
157159 "read_kwargs" : read_kwargs .copy (),
0 commit comments