lib.App: Refactor App / Cmd to adress multiple functionality and style issues #60
1 changed files with 5 additions and 5 deletions
lib.App: Use parser in _add_arguments()
_add_arguments() adds the global options to self.__parser instead of to the parser it receives. The two are the same object, because the only caller passes self.__parser, so the change is not observable. Use the parser parameter instead, so that the method honors its argument the way Cmd.add_arguments() does, and so that the global options can be shared with other parsers, e.g. the subcommand parsers, without rewriting this method. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2 Signed-off-by: Jan Lindemann <jan@janware.com>
commit
0be539a40a
|
|
@ -46,28 +46,28 @@ def _get_current_event_loop() -> asyncio.AbstractEventLoop | None:
|
|||
class App: # export
|
||||
|
||||
def _add_arguments(self, parser: ArgumentParser) -> None:
|
||||
self.__parser.add_argument(
|
||||
parser.add_argument(
|
||||
'--log-flags',
|
||||
help = 'Log flags',
|
||||
default = self.__default_log_flags,
|
||||
type = parse_log_flags,
|
||||
)
|
||||
self.__parser.add_argument(
|
||||
parser.add_argument(
|
||||
'--log-level',
|
||||
help = 'Log level',
|
||||
default = self.__default_log_level,
|
||||
type = parse_log_level,
|
||||
)
|
||||
self.__parser.add_argument(
|
||||
parser.add_argument(
|
||||
'--log-file', help = 'Log file', default = self.__default_log_file
|
||||
)
|
||||
self.__parser.add_argument(
|
||||
parser.add_argument(
|
||||
'--backtrace',
|
||||
help = 'Show exception backtraces',
|
||||
action = 'store_true',
|
||||
default = self.__back_trace,
|
||||
)
|
||||
self.__parser.add_argument(
|
||||
parser.add_argument(
|
||||
'--write-profile',
|
||||
help = 'Profile code and store output to file',
|
||||
default = None,
|
||||
|
|
|
|||
Loading…
Reference in a new issue