Skip to content

feat: add monitor templates and export/import#2

Merged
lu-zhengda merged 1 commit into
mainfrom
feat/monitor-templates-export
Feb 15, 2026
Merged

feat: add monitor templates and export/import#2
lu-zhengda merged 1 commit into
mainfrom
feat/monitor-templates-export

Conversation

@lu-zhengda

Copy link
Copy Markdown
Owner

Summary

  • Add four monitoring-focused templates (monitor-cpu, monitor-ports, monitor-security, monitor-disk) that create launchd agents scheduling toolkit CLIs (pstop, whport, macdog, macbroom) to run on intervals
  • Monitor templates auto-generate labels (com.lanchr.monitor-*) and include the program binary, so --label and --program flags become optional when using them
  • Add export <label> [file] subcommand that serializes a launch agent/daemon to a portable JSON bundle (stdout if no file specified)
  • Add import <file> subcommand that restores a launch agent from an export bundle to ~/Library/LaunchAgents/ with optional --load flag
  • Add WriteWithoutValidation method for importing plists where referenced binaries may not exist yet
  • Add completions/ to .gitignore
  • Add comprehensive unit tests for bundle round-trip, template defaults, and writer validation

Test plan

  • go build ./... passes
  • go vet ./... passes
  • go test -race ./... passes (14 tests in plist package)
  • Manual: lanchr create --template monitor-cpu generates correct plist with auto-label
  • Manual: lanchr export <label> /tmp/test.json produces valid JSON bundle
  • Manual: lanchr import /tmp/test.json --load restores and loads the agent
  • Verify existing commands (list, info, create with non-monitor templates) still work

Add four monitoring-focused templates (monitor-cpu, monitor-ports,
monitor-security, monitor-disk) that schedule toolkit CLIs via launchd.
Monitor templates auto-generate labels and programs from the template,
so --label and --program flags become optional.

Add export subcommand that serializes a launch agent/daemon (plist +
metadata) to a portable JSON bundle, writing to a file or stdout.

Add import subcommand that restores a launch agent from an export
bundle, copying the plist to ~/Library/LaunchAgents/ with optional
--load flag to bootstrap immediately.

Also adds completions/ to .gitignore and comprehensive tests for
the new bundle, template, and writer functionality.
@lu-zhengda
lu-zhengda merged commit 70d28da into main Feb 15, 2026
1 check 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.

1 participant