File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -306,6 +306,25 @@ def run(cm, args):
306306 )
307307
308308
309+ def config (cm , args ):
310+
311+ conf = Config (path = args .config if args .config else None )
312+
313+ if not hasattr (conf , args .key ):
314+ logger .error (f"Invalid config parameter: { args .key } " )
315+ exit (1 )
316+
317+ if not args .value :
318+ # Read
319+ if hasattr (conf , args .key ):
320+ print (getattr (conf , args .key ))
321+ else :
322+ # Write
323+ if hasattr (conf , args .key ):
324+ setattr (conf , args .key , args .value )
325+ conf .write ()
326+
327+
309328# Clean out old work root
310329def prepare_work_root (work_root ):
311330 if os .path .exists (work_root ):
@@ -720,6 +739,17 @@ def get_parser():
720739 )
721740 parser_run .set_defaults (func = run )
722741
742+ # config subparser
743+ parser_config = subparsers .add_parser (
744+ "config" ,
745+ help = "Read/write config default section [" + Config .default_section + "]" ,
746+ )
747+ parser_config .set_defaults (func = config )
748+ parser_config .add_argument ("key" , help = "Config parameter" )
749+ parser_config .add_argument (
750+ "value" , nargs = argparse .OPTIONAL , help = "Config parameter"
751+ )
752+
723753 return parser
724754
725755
You can’t perform that action at this time.
0 commit comments