Parse command line arguments and merge them with JSON configuration. This function first parses command line arguments, then loads configuration from a JSON file specified by the 'cfg' argument, and finally merges both configurations with command line arguments taking precedence. P
(parser: argparse.ArgumentParser)
| 24 | |
| 25 | |
| 26 | def parse_args(parser: argparse.ArgumentParser) -> argparse.Namespace: |
| 27 | """Parse command line arguments and merge them with JSON configuration. |
| 28 | |
| 29 | This function first parses command line arguments, then loads configuration |
| 30 | from a JSON file specified by the 'cfg' argument, and finally merges both |
| 31 | configurations with command line arguments taking precedence. |
| 32 | |
| 33 | Parameters |
| 34 | ---------- |
| 35 | parser : argparse.ArgumentParser |
| 36 | Argument parser instance with defined arguments. |
| 37 | |
| 38 | Returns |
| 39 | ------- |
| 40 | argparse.Namespace |
| 41 | Merged configuration from both command line and JSON file. |
| 42 | """ |
| 43 | entry = parser.parse_args() |
| 44 | args = json_to_args(entry.cfg) |
| 45 | args.__dict__.update(vars(entry)) |
| 46 | return args |
no test coverage detected