File tree Expand file tree Collapse file tree 1 file changed +25
-7
lines changed
Expand file tree Collapse file tree 1 file changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -58,13 +58,31 @@ def contains_list_type(annotation) -> bool:
5858 description = field .description
5959 if field .default is not None and description is not None :
6060 description += f" (default: { field .default } )"
61- parser .add_argument (
62- f"--{ name } " ,
63- dest = name ,
64- nargs = "*" if contains_list_type (field .annotation ) else None ,
65- type = get_base_type (field .annotation ) if field .annotation is not None else str ,
66- help = description ,
67- )
61+ base_type = get_base_type (field .annotation ) if field .annotation is not None else str
62+ list_type = contains_list_type (field .annotation )
63+ if base_type is not bool :
64+ parser .add_argument (
65+ f"--{ name } " ,
66+ dest = name ,
67+ nargs = "*" if list_type else None ,
68+ type = base_type ,
69+ help = description ,
70+ )
71+ if base_type is bool :
72+ parser .add_argument (
73+ f"--{ name } " ,
74+ dest = name ,
75+ action = "store_true" ,
76+ help = f"Disable { description } " ,
77+ default = field .default ,
78+ )
79+ parser .add_argument (
80+ f"--no-{ name } " ,
81+ dest = name ,
82+ action = "store_false" ,
83+ help = f"Disable { description } " ,
84+ default = field .default ,
85+ )
6886
6987 args = parser .parse_args ()
7088 settings = Settings (** {k : v for k , v in vars (args ).items () if v is not None })
You can’t perform that action at this time.
0 commit comments