Skip to content

Commit 173e13f

Browse files
authored
Merge pull request #2 from Flowduino/feature/observable-callback-coverage
Feature/observable callback coverage
2 parents b34d2a7 + d2ef6c9 commit 173e13f

10 files changed

Lines changed: 267 additions & 51 deletions

.github/workflows/tests.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ name: Tests
22

33
on:
44
push:
5+
branches:
6+
- main
7+
- feature/observable-callback-coverage
58
pull_request:
9+
branches:
10+
- main
611

712
jobs:
813
host-tests:
@@ -15,3 +20,41 @@ jobs:
1520
run: cmake --build build --parallel
1621
- name: Test
1722
run: ctest --test-dir build --output-on-failure
23+
24+
esp32-example:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: actions/checkout@v4
29+
with:
30+
repository: Flowduino/ESPressio-Observable
31+
ref: 3.0.1
32+
path: deps/ESPressio-Observable
33+
- name: Install PlatformIO
34+
run: pip install platformio
35+
- name: Create PlatformIO consumer project
36+
shell: bash
37+
run: |
38+
mkdir -p "$RUNNER_TEMP/espressio-command-ci/src" "$RUNNER_TEMP/espressio-command-ci/lib"
39+
rsync -a --exclude='.git' --exclude='deps' --exclude='build' ./ "$RUNNER_TEMP/espressio-command-ci/lib/ESPressio-Command/"
40+
cp -R deps/ESPressio-Observable "$RUNNER_TEMP/espressio-command-ci/lib/ESPressio-Observable"
41+
cat > "$RUNNER_TEMP/espressio-command-ci/platformio.ini" <<'EOF'
42+
[env:esp32dev]
43+
platform = espressif32
44+
board = esp32dev
45+
framework = arduino
46+
build_flags =
47+
-std=gnu++17
48+
-frtti
49+
build_unflags =
50+
-std=gnu++11
51+
-fno-rtti
52+
lib_deps =
53+
ESPressio-Command
54+
ESPressio-Observable
55+
EOF
56+
- name: Compile BasicCommand
57+
shell: bash
58+
run: |
59+
cp examples/BasicCommand/BasicCommand.ino "$RUNNER_TEMP/espressio-command-ci/src/main.cpp"
60+
pio run -d "$RUNNER_TEMP/espressio-command-ci"

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.3.0
2+
3+
- Added `ICommandRegistryObserver` and observer registration on `CommandRegistry`.
4+
- Added notifications for root command registration and unregistration, including scoped `CommandRegistrationHandle` lifetime removal.
5+
- Added ESPressio Observable as the registry-observer dependency.
6+
- Added optional ESPressio Event bridge support through ESPressio Event 5.8.0.
7+
18
## 0.2.0
29

310
- Added ownership-safe `CommandRegistrationHandle` for scoped command registration.

README.md

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ USB CDC, TCP, WebSocket, BLE, HTTP, test harnesses and programmatic callers can
99
therefore share the same Command tree, parameter definitions, validation and
1010
callbacks without coupling application logic to a transport.
1111

12+
## 0.3.0 Development Update — Observable Callback Coverage
13+
14+
The `feature/observable-callback-coverage` branch targets **ESPressio Command 0.3.0**. The stable/pre-release information below remains the 0.2.0 documentation until 0.3.0 is released.
15+
16+
Command 0.3.0 adds a required dependency on **ESPressio Observable >= 3.0.1 and < 4.0.0** and introduces `ICommandRegistryObserver`. `CommandRegistry` now reports root command registration and successful unregistration, including scoped `CommandRegistrationHandle` cleanup. Command invocation itself deliberately remains on the existing callbacks, middleware, `Before(...)` and `After(...)` hooks rather than being duplicated as Observable traffic.
17+
18+
ESPressio Event remains **optional**. ESPressio Event 5.8.0 provides `CommandRegistryEventBridge`, which converts registry lifecycle observations into asynchronous `CommandRegisteredEvent` and `CommandUnregisteredEvent` instances without making Event a Command dependency.
19+
20+
Development-branch PlatformIO dependencies are:
21+
22+
```ini
23+
lib_deps =
24+
https://github.com/Flowduino/ESPressio-Command.git#feature/observable-callback-coverage
25+
flowduino/ESPressio-Observable@^3.0.1
26+
```
27+
28+
The host tests include dedicated registry-observer lifecycle coverage. See [CHANGELOG.md](CHANGELOG.md) for the complete 0.3.0 change list.
29+
1230
## Latest Stable Version
1331

1432
ESPressio Command is currently **0.2.0 (pre-release)**.
@@ -23,7 +41,7 @@ family under Arduino-ESP32** as part of the ESPressio Development Platform.
2341

2442
The Command core is deliberately transport-neutral and does not directly depend
2543
on Arduino `Stream`, `Print`, ESPressio Serial, ESPressio Event, a network
26-
stack, or any other ESPressio component library.
44+
stack, or any other ESPressio component library. Beginning with the 0.3.0 development generation it does require ESPressio Observable 3.x for its registry lifecycle surface.
2745

2846
Host-side tests are also provided so that the transport-neutral core can be
2947
validated with a conventional C++17 toolchain.
@@ -84,12 +102,9 @@ In the dependency chart:
84102

85103
### Required ESPressio dependencies
86104

87-
**None.**
105+
The stable 0.2.0 pre-release has no ESPressio dependency. **The 0.3.0 development branch requires ESPressio Observable >= 3.0.1 and < 4.0.0.**
88106

89-
ESPressio Command is intentionally dependency-free within the ESPressio
90-
ecosystem. Future Serial, Event, networking, Serializable or other integrations
91-
should depend on Command or be provided as opt-in adapters; they must not become
92-
mandatory dependencies of the Command core.
107+
Serial, Event, networking, Serializable and other integrations should depend on Command or be provided as opt-in adapters; they must not become mandatory dependencies of the Command core. Event remains opt-in even though 5.8.0 provides a Command registry Event bridge.
93108

94109
## Namespace
95110

@@ -110,16 +125,20 @@ The principal public types are:
110125
- `TextCommandParser` — converts textual Command lines into tokens.
111126
- `CommandLine` — incrementally consumes character/buffer input.
112127
- `CommandFactory` — convenient facade for Command registration.
128+
- `CommandRegistrationHandle` — ownership-safe scoped dynamic registration.
129+
- `ICommandRegistryObserver` — 0.3.0 registry lifecycle observer.
113130

114131
## PlatformIO
115132

116-
You can add the published library to a PlatformIO project with:
133+
For the stable/pre-release 0.2.0 generation:
117134

118135
```ini
119136
lib_deps =
120137
flowduino/ESPressio-Command@^0.2.0
121138
```
122139

140+
For 0.3.0, consume ESPressio Observable 3.x as shown in the development update above.
141+
123142
Until a release/tag is published, or when deliberately consuming the latest
124143
integration sources, use:
125144

@@ -302,6 +321,31 @@ These extension points allow policy, diagnostics and integration behaviour to
302321
be layered around Command execution without coupling those concerns to the
303322
Command callback itself.
304323

324+
## Observable Registry Lifecycle (0.3.0)
325+
326+
Registry topology changes can now be observed without changing command execution semantics:
327+
328+
```cpp
329+
class RegistryObserver final :
330+
public ESPressio::Command::ICommandRegistryObserver {
331+
public:
332+
void OnCommandRegistered(const std::vector<std::string>& path) override {
333+
// Passive diagnostics / discovery refresh.
334+
}
335+
336+
void OnCommandUnregistered(const std::vector<std::string>& path) override {
337+
// Owned registration lifetime ended.
338+
}
339+
};
340+
341+
RegistryObserver observer;
342+
auto observerHandle = commands.RegisterObserver(&observer);
343+
```
344+
345+
New root creation and successful root removal emit notifications. Duplicate registration attempts that do not change the tree do not emit. `CommandRegistrationHandle::Reset()` and handle destruction flow through the same successful-unregistration path.
346+
347+
With ESPressio Event 5.8.0 selected, `CommandRegistryEventBridge` can convert these facts into asynchronous Events. Event remains an optional downstream adapter.
348+
305349
## Incremental Text Input
306350

307351
`CommandLine` accepts characters or buffers and submits complete lines to a
@@ -386,7 +430,7 @@ rules:
386430
5. **Transport and protocol integrations belong outside the core.**
387431
6. **Cross-cutting behaviour should be implemented through middleware or
388432
focused hooks rather than embedded in application callbacks.**
389-
7. **The core remains independently useful and dependency-free.**
433+
7. **The core remains independently useful; from 0.3.0 its only required ESPressio dependency is Observable.**
390434

391435
## Examples
392436

@@ -404,7 +448,7 @@ Host-side tests are provided beneath [`tests/`](tests/).
404448
They exercise the transport-neutral Command implementation independently of
405449
Arduino hardware. This keeps parsing, resolution, validation and invocation
406450
behaviour testable with a conventional C++17 toolchain while embedded examples
407-
validate intended ESP32 integration usage.
451+
validate intended ESP32 integration usage. The 0.3.0 generation also validates registry-observer registration lifetime and notification semantics.
408452

409453
## Future Integration Direction
410454

@@ -420,15 +464,15 @@ ESPressio Command is intended to become the common invocation layer for:
420464
- cancellation/progress for asynchronous operations;
421465
- remote Command invocation;
422466
- JSON/Serializable argument adapters; and
423-
- Event bridges for Command completion/result Events.
467+
- Event bridges for Command lifecycle/completion/result Events where those asynchronous representations are justified.
424468

425469
These integrations should remain **opt-in**. The dependency direction is
426470
important:
427471

428472
```text
429473
Serial adapter --------+
430474
Network adapter -------+
431-
Serializable adapter --+--> ESPressio Command
475+
Serializable adapter --+--> ESPressio Command --> ESPressio Observable
432476
Event bridge ----------+
433477
```
434478

component.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ COMPONENT_SRCDIRS := src
33

44
CXXFLAGS += -DESPRESSIO_COMMAND
55
CXXFLAGS += -DESPRESSIO_COMMAND_VERSION_MAJOR=0
6-
CXXFLAGS += -DESPRESSIO_COMMAND_VERSION_MINOR=2
6+
CXXFLAGS += -DESPRESSIO_COMMAND_VERSION_MINOR=3
77
CXXFLAGS += -DESPRESSIO_COMMAND_VERSION_PATCH=0
8-
CXXFLAGS += -DESPRESSIO_COMMAND_VERSION_STRING=\"0.2.0\"
8+
CXXFLAGS += -DESPRESSIO_COMMAND_VERSION_STRING=\"0.3.0\"
99
CXXFLAGS += -std=gnu++17

library.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ESPressio-Command",
33
"description": "Transport-neutral typed command definition, parsing, routing and invocation framework for ESP32 and C++17",
4-
"keywords": "command,commands,cli,console,parser,router,dispatcher,espressio",
4+
"keywords": "command,commands,cli,console,parser,router,dispatcher,observable,espressio",
55
"authors": {
66
"name": "Flowduino",
77
"maintainer": true,
@@ -17,8 +17,15 @@
1717
"type": "git",
1818
"url": "https://github.com/Flowduino/ESPressio-Command.git"
1919
},
20-
"version": "0.2.0",
20+
"version": "0.3.0",
2121
"license": "Apache-2.0",
2222
"frameworks": "*",
23-
"platforms": "*"
23+
"platforms": "*",
24+
"dependencies": [
25+
{
26+
"name": "Flowduino ESPressio-Observable",
27+
"version": ">=3.0.1 <4.0.0",
28+
"url": "https://github.com/Flowduino/ESPressio-Observable.git"
29+
}
30+
]
2431
}

library.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name=Flowduino ESPressio-Command
2-
version=0.2.0
2+
version=0.3.0
33
author=Simon J. Stuart
44
maintainer=Flowduino.com
55
sentence=Transport-neutral typed command routing and invocation framework
6-
paragraph=Defines hierarchical commands, typed positional and named parameters, validation, help, completion, middleware and callbacks independently of Serial, TCP, WebSocket or other input transports.
6+
paragraph=Defines hierarchical commands, typed positional and named parameters, validation, help, completion, middleware, callbacks and observable command-registry lifecycle notifications independently of Serial, TCP, WebSocket or other input transports.
77
category=Other
88
url=https://github.com/Flowduino/ESPressio-Command
99
architectures=*
1010
includes=ESPressio_Command.hpp,ESPressio_CommandFactory.hpp,ESPressio_CommandLine.hpp,ESPressio_Commands.hpp
11+
depends=Flowduino ESPressio-Observable (>=3.0.1)

0 commit comments

Comments
 (0)