-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Migrate zday CLI to cli-core-yo foundation #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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
There was a problem hiding this 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".
| <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"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 / 👎.
| else: | ||
| ctx = ssl._create_unverified_context() | ||
| conn = http.client.HTTPSConnection( | ||
| ip_addr, | ||
| 443, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Summary
Migrates the
zdayCLI from a raw Typer implementation to usecli-core-yoas 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)
8eb4f6bTyper()withcreate_app(spec), convert 8 command modules toregister()plugin pattern621a756console.print()tooutput.*primitives4c13ac2--json/-jflag, remove per-command--jsonflags, wire toRuntimeContext236907azday simulator start/stop/list) + refactor scanner to ZPL-first discovery with optional HTTP fallback24d1bc18d6230eff34f4fQuality Gates
New Features
Printer Simulator
zday simulator start— Launch mock Zebra printer with ZPL TCP (port 9100) + HTTP serverzday simulator stop/zday simulator list— Manage running simulators~HI,~HS,~HQSN,~HQOD,~HQESZPL queriesZPL-First Network Scanner
cmd_mgr.ZebraPrinter.get_host_identification()--scan-http-portflag for HTTP fallbacknotesfield:"zpl","http(80)", or"zpl+http(80)"Documentation
--jsonflag, simulator section, ZPL-first scanner section, updated CLI referenceBreaking Changes
None. All existing CLI commands, flags, and behavior are preserved. The
--jsonflag moved from per-command to global position (zday --json <command>).Dependencies
cli-core-yo>=0.2.1,<0.3.0typer>=0.21.0,<0.22.0(was>=0.9.0),rich>=14.0.0,<15.0.0Pull Request opened by Augment Code with guidance from the PR author