@@ -657,25 +657,32 @@ def resolve(self, config: RunConfig) -> RunConfig:
657657 return resolved_cfg
658658
659659 def __repr__ (self ) -> str :
660- # make it a pretty printable dict
661- pretty_opts = {}
662- for cfg_key , runopt in self ._opts .items ():
663- key = f"*{ cfg_key } " if runopt .is_required else cfg_key
664- opt = {"type" : get_type_name (runopt .opt_type )}
665- if runopt .is_required :
666- opt ["required" ] = "True"
667- else :
668- opt ["default" ] = str (runopt .default )
669- opt ["help" ] = runopt .help
670-
671- pretty_opts [key ] = opt
672- import pprint
673-
674- return pprint .pformat (
675- pretty_opts ,
676- indent = 2 ,
677- width = 80 ,
678- )
660+ required = [(key , opt ) for key , opt in self ._opts .items () if opt .is_required ]
661+ optional = [
662+ (key , opt ) for key , opt in self ._opts .items () if not opt .is_required
663+ ]
664+
665+ out = " usage:\n "
666+ for i , (key , opt ) in enumerate (required + optional ):
667+ contents = f"{ key } ={ key .upper ()} "
668+ if not opt .is_required :
669+ contents = f"[{ contents } ]"
670+ if i > 0 :
671+ contents = "," + contents
672+ out += contents
673+
674+ sections = [("required" , required ), ("optional" , optional )]
675+
676+ for section , opts in sections :
677+ if len (opts ) == 0 :
678+ continue
679+ out += f"\n \n { section } arguments:"
680+ for key , opt in opts :
681+ default = "" if opt .is_required else f", { opt .default } "
682+ out += f"\n { key } ={ key .upper ()} ({ get_type_name (opt .opt_type )} { default } )"
683+ out += f"\n { opt .help } "
684+
685+ return out
679686
680687
681688class InvalidRunConfigException (Exception ):
0 commit comments