lib.ExecApp: Add class #79

Merged
Jan Lindemann merged 1 commit from jan/feature/20260822-lib-execapp-add-class into master 2026-08-22 17:31:57 +02:00 AGit

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.

#### 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.
lib.ExecApp: Add class
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 10m28s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m14s
CI / Packaging test (pull_request) Successful in 0s
42f6c1d14b
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
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-08-22 17:17:11 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
janware/jw-pkg!79
No description provided.