Skip to content

Refactor: split main.zig into modular CLI modules#15

Merged
linyows merged 3 commits into
mainfrom
refactor-split-main-into-cli-modules
Apr 19, 2026
Merged

Refactor: split main.zig into modular CLI modules#15
linyows merged 3 commits into
mainfrom
refactor-split-main-into-cli-modules

Conversation

@linyows

@linyows linyows commented Apr 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Split src/main.zig (2251 lines) into 5 focused modules under src/cli/
  • Reduce main.zig to 146 lines (entry point + arg parsing only)
  • No functional changes, all tests pass

Module structure

File Lines Responsibility
cli/ui.zig 168 UI constants, table formatting, color helpers
cli/data.zig 304 Data loading, filtering, date utilities
cli/enrich.zig 98 IP enrichment display helpers
cli/show.zig 480 show/list commands
cli/commands.zig 1022 fetch/enrich/aggregate/dns/domains/summary/check commands

Test plan

  • zig build compiles successfully
  • zig build test all tests pass
  • zig build run -- version works correctly
  • zig build run -- help works correctly

🤖 Generated with Claude Code

linyows and others added 3 commits April 19, 2026 22:00
Extract 2251-line main.zig into focused modules under src/cli/:
- ui.zig: UI constants, table formatting, color helpers
- data.zig: data loading, filtering, date utilities
- enrich.zig: IP enrichment display helpers
- show.zig: show/list commands
- commands.zig: fetch/enrich/aggregate/dns/domains/summary/check commands

main.zig is now 146 lines (entry point + arg parsing only).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors the Zig CLI entrypoint by splitting the previously large src/main.zig into focused modules under src/cli/, keeping main.zig as a thin dispatcher/arg parser.

Changes:

  • Moved command implementations into src/cli/commands.zig (fetch/enrich/aggregate/dns/domains/summary/check) and src/cli/show.zig (show/list).
  • Extracted shared helpers into src/cli/ui.zig (output formatting/constants) and src/cli/data.zig / src/cli/enrich.zig (data + enrichment utilities).
  • Updated src/main.zig to delegate to the new modules and to re-export submodule tests for the executable test target.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main.zig Reduced to CLI entrypoint + arg parsing; dispatches to new cli/* modules; pulls in submodule tests.
src/cli/ui.zig Adds shared UI constants and table formatting helpers used across CLI commands.
src/cli/data.zig Centralizes report loading/filtering and date/time utilities used by multiple commands.
src/cli/enrich.zig Extracts cached IP enrichment helpers and TLS enrichment line formatting.
src/cli/show.zig Implements show/list commands and table/JSON output using shared helpers.
src/cli/commands.zig Implements non-show commands (fetch/enrich/aggregate/dns/domains/summary/check) using shared helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@linyows linyows merged commit 9d8829e into main Apr 19, 2026
6 checks passed
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.

2 participants