lib.App: Refactor App / Cmd to adress multiple functionality and style issues #60

Merged
Jan Lindemann merged 12 commits from jan/fix/20260815-lib-app-cmd-refactor-multiple-functionality-and-style-issues into master 2026-08-15 16:07:54 +02:00 AGit
Showing only changes of commit 0be539a40a - Show all commits

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>
Jan Lindemann 2026-08-14 23:53:23 +02:00
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -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,