keep-github-workflows-active 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ """Public package surface exposing greeting, failure, and metadata hooks."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .behaviors import (
6
+ CANONICAL_GREETING,
7
+ emit_greeting,
8
+ noop_main,
9
+ raise_intentional_failure,
10
+ )
11
+ from .__init__conf__ import print_info
12
+
13
+ __all__ = [
14
+ "CANONICAL_GREETING",
15
+ "emit_greeting",
16
+ "noop_main",
17
+ "print_info",
18
+ "raise_intentional_failure",
19
+ ]
@@ -0,0 +1,67 @@
1
+ """Static package metadata surfaced to CLI commands and documentation.
2
+
3
+ Purpose
4
+ -------
5
+ Expose the current project metadata as simple constants. These values are kept
6
+ in sync with ``pyproject.toml`` by development automation (tests, push
7
+ pipelines), so runtime code does not query packaging metadata.
8
+
9
+ Contents
10
+ --------
11
+ * Module-level constants describing the published package.
12
+ * :func:`print_info` rendering the constants for the CLI ``info`` command.
13
+
14
+ System Role
15
+ -----------
16
+ Lives in the adapters/platform layer; CLI transports import these constants to
17
+ present authoritative project information without invoking packaging APIs.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ #: Distribution name declared in ``pyproject.toml``.
23
+ name = "keep_github_workflows_active"
24
+ #: Human-readable summary shown in CLI help output.
25
+ title = "Template for python apps with registered cli commands"
26
+ #: Current release version pulled from ``pyproject.toml`` by automation.
27
+ version = "2.0.0"
28
+ #: Repository homepage presented to users.
29
+ homepage = "https://github.com/bitranox/keep_github_workflows_active"
30
+ #: Author attribution surfaced in CLI output.
31
+ author = "bitranox"
32
+ #: Contact email surfaced in CLI output.
33
+ author_email = "bitranox@gmail.com"
34
+ #: Console-script name published by the package.
35
+ shell_command = "keep-github-workflows-active"
36
+
37
+
38
+ def print_info() -> None:
39
+ """Print the summarised metadata block used by the CLI ``info`` command.
40
+
41
+ Why
42
+ Provides a single, auditable rendering function so documentation and
43
+ CLI output always match the system design reference.
44
+
45
+ Side Effects
46
+ Writes to ``stdout``.
47
+
48
+ Examples
49
+ --------
50
+ >>> print_info() # doctest: +ELLIPSIS
51
+ Info for keep_github_workflows_active:
52
+ ...
53
+ """
54
+
55
+ fields = [
56
+ ("name", name),
57
+ ("title", title),
58
+ ("version", version),
59
+ ("homepage", homepage),
60
+ ("author", author),
61
+ ("author_email", author_email),
62
+ ("shell_command", shell_command),
63
+ ]
64
+ pad = max(len(label) for label, _ in fields)
65
+ lines = [f"Info for {name}:", ""]
66
+ lines.extend(f" {label.ljust(pad)} = {value}" for label, value in fields)
67
+ print("\n".join(lines))
@@ -0,0 +1,114 @@
1
+ """Module entry point ensuring SystemExit semantics match project standards.
2
+
3
+ Purpose
4
+ -------
5
+ Provide the ``python -m keep_github_workflows_active`` path mandated by the
6
+ project's packaging guidelines. The wrapper delegates to
7
+ :func:`keep_github_workflows_active.cli.main` so that module execution mirrors the
8
+ installed console script, including traceback handling and exit-code mapping.
9
+
10
+ Contents
11
+ --------
12
+ * :func:`_open_cli_session` – wires ``cli_session`` with the agreed limits.
13
+ * :func:`_command_to_run` / :func:`_command_name` – expose the command and label
14
+ used by the module entry.
15
+ * :func:`_module_main` – drives execution and returns the exit code.
16
+
17
+ System Role
18
+ -----------
19
+ Lives in the adapters layer. It bridges CPython's module execution entry point
20
+ to the shared CLI helper while reusing the same ``cli_session`` orchestration
21
+ documented in ``docs/systemdesign/module_reference.md``.
22
+ """
23
+
24
+ from __future__ import annotations
25
+
26
+ from collections.abc import Callable
27
+ from contextlib import AbstractContextManager
28
+ from typing import Final
29
+
30
+ from lib_cli_exit_tools import cli_session
31
+ import rich_click as click
32
+
33
+ from . import __init__conf__, cli
34
+
35
+ # Match the CLI defaults so truncation behaviour stays consistent across entry
36
+ # points regardless of whether users call the console script or ``python -m``.
37
+ #: Character budget for truncated tracebacks when running via module entry.
38
+ TRACEBACK_SUMMARY_LIMIT: Final[int] = cli.TRACEBACK_SUMMARY_LIMIT
39
+ #: Character budget for verbose tracebacks when running via module entry.
40
+ TRACEBACK_VERBOSE_LIMIT: Final[int] = cli.TRACEBACK_VERBOSE_LIMIT
41
+
42
+
43
+ CommandRunner = Callable[..., int]
44
+
45
+
46
+ def _open_cli_session() -> AbstractContextManager[CommandRunner]:
47
+ """Return the configured ``cli_session`` context manager.
48
+
49
+ Why
50
+ ``cli_session`` wires ``lib_cli_exit_tools`` with the tracing limits we
51
+ want for module execution. Wrapping it keeps the configuration in a
52
+ single place.
53
+
54
+ Outputs
55
+ AbstractContextManager[CommandRunner]:
56
+ Context manager that yields the callable responsible for invoking
57
+ the Click command.
58
+ """
59
+
60
+ return cli_session(
61
+ summary_limit=TRACEBACK_SUMMARY_LIMIT,
62
+ verbose_limit=TRACEBACK_VERBOSE_LIMIT,
63
+ )
64
+
65
+
66
+ def _command_to_run() -> click.Command:
67
+ """Expose the click command that powers the module entry.
68
+
69
+ Why
70
+ Keeps the module entry explicit about which command is being executed
71
+ while remaining easy to stub in tests.
72
+
73
+ Outputs
74
+ click.Command: reference to the root CLI command group.
75
+ """
76
+
77
+ return cli.cli
78
+
79
+
80
+ def _command_name() -> str:
81
+ """Return the shell-friendly name announced by the session.
82
+
83
+ Why
84
+ ``lib_cli_exit_tools`` uses this value when presenting help and error
85
+ messages; we centralise the derivation so tests can assert against it.
86
+
87
+ Outputs
88
+ str: Name of the console script as published through entry points.
89
+ """
90
+
91
+ return __init__conf__.shell_command
92
+
93
+
94
+ def _module_main() -> int:
95
+ """Execute the CLI entry point and return a normalised exit code.
96
+
97
+ Why
98
+ Implements ``python -m keep_github_workflows_active`` by delegating to the
99
+ shared CLI composition while respecting the configured traceback
100
+ budgets.
101
+
102
+ Outputs
103
+ int: Exit code reported by the CLI run.
104
+ """
105
+
106
+ with _open_cli_session() as run:
107
+ return run(
108
+ _command_to_run(),
109
+ prog_name=_command_name(),
110
+ )
111
+
112
+
113
+ if __name__ == "__main__":
114
+ raise SystemExit(_module_main())
@@ -0,0 +1,145 @@
1
+ """Domain-level behaviors supporting the minimal CLI transport.
2
+
3
+ Purpose
4
+ -------
5
+ Collect the placeholder behaviors that the CLI adapter exposes so that each
6
+ concern remains self-contained. Keeping these helpers together makes it easy to
7
+ swap in richer logging logic later without touching the transport surface.
8
+
9
+ Contents
10
+ --------
11
+ * :func:`emit_greeting` – success-path helper that writes the canonical scaffold
12
+ message.
13
+ * :func:`raise_intentional_failure` – deterministic error hook used by tests and
14
+ CLI flows to validate traceback handling.
15
+ * :func:`noop_main` – placeholder entry used when callers expect a ``main``
16
+ callable despite the domain layer being stubbed today.
17
+
18
+ System Role
19
+ -----------
20
+ Acts as the temporary domain surface for this template. Other modules import
21
+ from here instead of duplicating literals so the public API stays coherent as
22
+ features evolve.
23
+ """
24
+
25
+ from __future__ import annotations
26
+
27
+ from typing import TextIO
28
+
29
+ import sys
30
+
31
+
32
+ CANONICAL_GREETING = "Hello World"
33
+
34
+
35
+ def _target_stream(preferred: TextIO | None) -> TextIO:
36
+ """Return the stream that should hear the greeting."""
37
+
38
+ return preferred if preferred is not None else sys.stdout
39
+
40
+
41
+ def _greeting_line() -> str:
42
+ """Return the greeting exactly as it should appear."""
43
+
44
+ return f"{CANONICAL_GREETING}\n"
45
+
46
+
47
+ def _flush_if_possible(stream: TextIO) -> None:
48
+ """Flush the stream when the stream knows how to flush."""
49
+
50
+ flush = getattr(stream, "flush", None)
51
+ if callable(flush):
52
+ flush()
53
+
54
+
55
+ def emit_greeting(*, stream: TextIO | None = None) -> None:
56
+ """Write the canonical greeting to the provided text stream.
57
+
58
+ Why
59
+ Provide a deterministic success path that the documentation, smoke
60
+ tests, and packaging checks can rely on while the real logging helpers
61
+ are developed.
62
+
63
+ What
64
+ Writes :data:`CANONICAL_GREETING` followed by a newline to the target
65
+ stream.
66
+
67
+ Parameters
68
+ ----------
69
+ stream:
70
+ Optional text stream receiving the greeting. Defaults to
71
+ :data:`sys.stdout` when ``None``.
72
+
73
+ Side Effects
74
+ Writes to the target stream and flushes it when a ``flush`` attribute is
75
+ available.
76
+
77
+ Examples
78
+ --------
79
+ >>> from io import StringIO
80
+ >>> buffer = StringIO()
81
+ >>> emit_greeting(stream=buffer)
82
+ >>> buffer.getvalue() == "Hello World\\n"
83
+ True
84
+ """
85
+
86
+ target = _target_stream(stream)
87
+ target.write(_greeting_line())
88
+ _flush_if_possible(target)
89
+
90
+
91
+ def raise_intentional_failure() -> None:
92
+ """Raise ``RuntimeError`` so transports can exercise failure flows.
93
+
94
+ Why
95
+ CLI commands and tests need a guaranteed failure scenario to ensure the
96
+ shared exit-code helpers and traceback toggles remain correct.
97
+
98
+ What
99
+ Always raises ``RuntimeError`` with the message ``"I should fail"``.
100
+
101
+ Side Effects
102
+ None beyond raising the exception.
103
+
104
+ Raises
105
+ RuntimeError: Regardless of input.
106
+
107
+ Examples
108
+ --------
109
+ >>> raise_intentional_failure()
110
+ Traceback (most recent call last):
111
+ ...
112
+ RuntimeError: I should fail
113
+ """
114
+
115
+ raise RuntimeError("I should fail")
116
+
117
+
118
+ def noop_main() -> None:
119
+ """Explicit placeholder callable for transports without domain logic yet.
120
+
121
+ Why
122
+ Some tools expect a module-level ``main`` even when the underlying
123
+ feature set is still stubbed out. Exposing this helper makes that
124
+ contract obvious and easy to replace later.
125
+
126
+ What
127
+ Performs no work and returns immediately.
128
+
129
+ Side Effects
130
+ None.
131
+
132
+ Examples
133
+ --------
134
+ >>> noop_main()
135
+ """
136
+
137
+ return None
138
+
139
+
140
+ __all__ = [
141
+ "CANONICAL_GREETING",
142
+ "emit_greeting",
143
+ "raise_intentional_failure",
144
+ "noop_main",
145
+ ]