lib.ExecApp: Add class
ExecApp is a ready-made base class for applications that operate through an ExecContext: it adds the --interactive, --verbose and --target options, exposes interactive, verbose and exec_context properties, and closes the exec context when the async context manager exits. The code for that has lived in jw.pkg.App code before, which now inherits from ExecApp. A fix along the way: __aexit__() closes the exec context and then chains to super().__aexit__(), so App.close() runs when the async context manager exits. Before the change, exiting the async context left the app unclosed; close() ran only on the run() path. Add a unit test that builds an ExecApp with a root command and asserts that close() runs on context exit and that the exec options are registered. The exec options are now registered before App's own options, which moves them up in the rendered --help output. Update the golden file of the help integration test to match. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2
This commit is contained in:
parent
eec9325b46
commit
1385b1a4ba
5 changed files with 167 additions and 77 deletions
|
|
@ -1,10 +1,11 @@
|
|||
============= Running: jw-pkg.py -t ../../../.. --log-level info --help
|
||||
usage: jw-pkg.py [--log-flags LOG_FLAGS] [--log-level LOG_LEVEL]
|
||||
[--log-file LOG_FILE] [--backtrace]
|
||||
[--write-profile WRITE_PROFILE] [-t TOPDIR]
|
||||
[--topdir-format TOPDIR_FORMAT] [-p PREFIX]
|
||||
[--distro-id DISTRO_ID] [--interactive {true,false,auto}]
|
||||
[--verbose] [--target TARGET] [--pkg-filter PKG_FILTER] [-h]
|
||||
[--write-profile WRITE_PROFILE]
|
||||
[--interactive {true,false,auto}] [--verbose]
|
||||
[--target TARGET] [-t TOPDIR] [--topdir-format TOPDIR_FORMAT]
|
||||
[-p PREFIX] [--distro-id DISTRO_ID] [--pkg-filter PKG_FILTER]
|
||||
[-h]
|
||||
...
|
||||
|
||||
jw-pkg swiss army knife
|
||||
|
|
@ -18,6 +19,12 @@ options:
|
|||
--backtrace Show exception backtraces (default: False)
|
||||
--write-profile WRITE_PROFILE
|
||||
Profile code and store output to file (default: None)
|
||||
--interactive {true,false,auto}
|
||||
Wait for user input or try to proceed unattended
|
||||
(default: true)
|
||||
--verbose Be verbose on stderr about what's being done on the
|
||||
distro level (default: False)
|
||||
--target TARGET Run commands on this host (default: local)
|
||||
-t, --topdir TOPDIR Project Path (default: None)
|
||||
--topdir-format TOPDIR_FORMAT
|
||||
Output references to topdir as one of "make:<var-
|
||||
|
|
@ -28,12 +35,6 @@ options:
|
|||
--distro-id DISTRO_ID
|
||||
Distribution ID (default is taken from /etc/os-
|
||||
release) (default: None)
|
||||
--interactive {true,false,auto}
|
||||
Wait for user input or try to proceed unattended
|
||||
(default: true)
|
||||
--verbose Be verbose on stderr about what's being done on the
|
||||
distro level (default: False)
|
||||
--target TARGET Run commands on this host (default: local)
|
||||
--pkg-filter PKG_FILTER
|
||||
Default filter for all distribution package-related
|
||||
operations (default: None)
|
||||
|
|
|
|||
Loading…
Reference in a new issue