Skip to content

Conversation

@iamh2o
Copy link
Contributor

@iamh2o iamh2o commented Feb 7, 2026

Summary

Migrates the zday CLI from a raw Typer implementation to use cli-core-yo as its foundation. This provides standardized output primitives, global JSON mode, XDG path management, and a plugin-based command registration system.

Also includes two new features developed during the migration: a mock Zebra printer simulator and ZPL-first network scanner.

Commits (7)

Commit Description
8eb4f6b Phase 0+1: Create feature branch, update deps, replace raw Typer() with create_app(spec), convert 8 command modules to register() plugin pattern
621a756 Phase 2: Convert 7 modules from console.print() to output.* primitives
4c13ac2 Phase 3: Add root callback with global --json/-j flag, remove per-command --json flags, wire to RuntimeContext
236907a New features: Add printer simulator (zday simulator start/stop/list) + refactor scanner to ZPL-first discovery with optional HTTP fallback
24d1bc1 Cleanup: Fix ruff lint/format issues in modified files
8d6230e Type safety: Resolve all 27 mypy errors across 9 files, fix 3 test failures
ff34f4f Docs: Update README, MODERNIZE, populate AGENTS.md, default simulator host 0.0.0.0

Quality Gates

Check Result
pytest 334/334 pass (13 test files)
mypy 0 errors (32 source files)
ruff check Clean on all modified files
ruff format Clean on all modified files

New Features

Printer Simulator

  • zday simulator start — Launch mock Zebra printer with ZPL TCP (port 9100) + HTTP server
  • zday simulator stop / zday simulator list — Manage running simulators
  • Responds to ~HI, ~HS, ~HQSN, ~HQOD, ~HQES ZPL queries
  • HTTP endpoint serves Zebra-like HTML for web-based discovery
  • 14 tests covering core ZPL responses, HTTP discovery, CLI commands, and manager lifecycle

ZPL-First Network Scanner

  • Default scan now probes port 9100 via cmd_mgr.ZebraPrinter.get_host_identification()
  • Optional --scan-http-port flag for HTTP fallback
  • Discovery method tracked in notes field: "zpl", "http(80)", or "zpl+http(80)"
  • Web UI scan forms updated with optional HTTP port field
  • 3 scanner integration tests

Documentation

  • README.md: Global --json flag, simulator section, ZPL-first scanner section, updated CLI reference
  • MODERNIZE.md: Phase 8 documentation
  • AGENTS.md: Project-specific agent directives

Breaking Changes

None. All existing CLI commands, flags, and behavior are preserved. The --json flag moved from per-command to global position (zday --json <command>).

Dependencies

  • Added: cli-core-yo>=0.2.1,<0.3.0
  • Updated: typer>=0.21.0,<0.22.0 (was >=0.9.0), rich>=14.0.0,<15.0.0

Pull Request opened by Augment Code with guidance from the PR author

- Add cli-core-yo>=0.2.1 dependency, update typer/rich pins
- Rewrite cli/__init__.py: CliSpec + create_app() replaces raw Typer
- Create cli/root_commands.py: status + bootstrap as plugin commands
- Add register() plugin functions to all 8 command modules
- Built-in version/info/config commands from cli-core-yo
- Custom validator for zebra-day config schema
- info_hooks for domain-specific info rows
- env group registered as custom plugin (Option C)
- All 39 tests pass unchanged
Replace console.print() patterns with cli-core-yo output primitives:
- output.success/error/warning/action/detail/heading/bullet/emit_json
- Full conversion: root_commands.py, gui.py (Console removed entirely)
- Partial conversion: printer.py, template.py, env.py, cognito.py, dynamo.py
  (Console retained only for Rich Table/Panel rendering)
- man.py skipped (heavy interactive Markdown/Panel rendering)
- All 39 tests pass unchanged
- Added root callback with --json/-j flag to cli/__init__.py
- RuntimeContext initialized before every command invocation
- Removed per-command --json flags from status, bootstrap, scan, list, template list, dynamo status
- Removed json_output parameter from _get_backend_from_env() helper
- Replaced all json_output checks with get_context().json_mode
- Simplified output code by relying on output.* auto-suppression in json_mode
- Updated test to pass --json as global flag before subcommand
- All 39 tests pass unchanged
Simulator (zebra_day/simulator.py, zebra_day/cli/simulator.py):
- SimulatedPrinter with ZPL TCP (port 9100) + HTTP servers
- Responds to ~HI, ~HQSN, ~HQES, ~HQOD, ~HS, ^XA^HH^XZ
- CLI: zday simulator start/stop/list
- SimulatorManager for fleet management

Scanner refactor (zebra_day/print_mgr.py):
- Default discovery now probes port 9100 via ~HI ZPL query
- Optional HTTP fallback via new scan_http_port parameter
- Discovery method tracked in notes field (zpl, http, zpl+http)
- Backward compatible: no scan_http_port = ZPL-only

CLI + Web UI:
- zday printer scan --scan-http-port flag
- HTTP port field added to config.html, config_new.html, printers.html
- /config/scan and /config/scan/stream routes accept scan_http_port

Tests: 56/56 pass (14 simulator + 3 scanner integration)
Mypy fixes (27 errors → 0):
- Replace datetime.UTC with datetime.timezone.utc (7 occurrences)
- Add explicit type annotations to avoid Returning Any errors (5 files)
- Rename output param to dest in template.py to avoid module shadowing
- Remove stale type: ignore comments (3 occurrences)
- Add ConfigBackend protocol annotation for polymorphic backend vars
- Add explicit Path/str casts for return values

Test fixes (3 failures → 0):
- Move --json flag before subcommand in test_cli_dynamo.py (global flag)
- Add scan_http_port param to fake_probe in test_web_server.py
- Emit JSON error via emit_json() instead of suppressed output.error()

Result: 334/334 tests pass, mypy 0 errors across 32 files
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d6230e4d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +79 to +81
<div class="form-group">
<label class="form-label">HTTP Port (optional)</label>
<input type="number" name="scan_http_port" class="form-control" placeholder="e.g. 80" min="1" max="65535">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pass scan_http_port through the SSE scan path

The new optional HTTP port input in the scan form is never sent when the JS SSE path is used. startNetworkScan() builds URLSearchParams with only ip_stub, scan_wait, and lab (see zebra_day/static/js/zebra_modern.js), so in browsers that support EventSource (the default), scan_http_port is dropped and the backend always receives None. That means the UI field appears to work but has no effect unless the browser falls back to the non-SSE submission path.

Useful? React with 👍 / 👎.

Comment on lines +316 to +320
else:
ctx = ssl._create_unverified_context()
conn = http.client.HTTPSConnection(
ip_addr,
443,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use scan_http_port for HTTPS probes too

In _http_probe, the HTTPS branch always connects to port 443 (HTTPSConnection(ip_addr, 443, ...)) instead of the scan_http_port the user provided. This makes scans miss printers that host their web UI on a non-443 HTTPS port (e.g., 8443), and also breaks the “HTTP redirect to HTTPS on same port” case. Since the CLI/UI explicitly allow a custom HTTP port, the HTTPS attempt should use the same port (or parse the redirect’s port) to honor the user’s input.

Useful? React with 👍 / 👎.

… 0.0.0.0

- README.md: add global --json flag docs, simulator section, ZPL-first scanner section, update CLI reference
- MODERNIZE.md: add Phase 8 (cli-core-yo + simulator + scanner), update commands reference
- AGENTS.md: populate project-specific agent directives
- simulator.py: change default --host from 127.0.0.1 to 0.0.0.0
@iamh2o iamh2o merged commit 441e651 into main Feb 8, 2026
5 of 14 checks passed
@iamh2o iamh2o deleted the feat/cli-core-yo-migration branch February 8, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant