Skip to content

Add watch mode with config interval support - #20

Merged
bigspawn merged 6 commits into
mainfrom
feature/watch-mode
Jan 7, 2026
Merged

Add watch mode with config interval support#20
bigspawn merged 6 commits into
mainfrom
feature/watch-mode

Conversation

@bigspawn

@bigspawn bigspawn commented Jan 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implement watch command for scheduled sync (Docker-friendly)
  • Add interval configuration via config.yaml with CLI override
  • Priority: CLI flag > Config file > Error (no auto-default)

Key Changes

  • cmd_watch.go: New watch command with interval validation (1h-168h)
  • config.go: Add WatchConfig struct with GetInterval() method
  • config.example.yaml: Add watch.interval field
  • README.md: Document watch mode and config options

Test plan

  • All tests pass
  • Lint clean
  • Config interval parsing works
  • CLI flag overrides config
  • Error when neither specified
  • Interval validation (1h-168h)

Fixes #19

Implements #19

Features:
- Add `watch` command for interval-based scheduled sync
- Interval validation: 1h minimum, 168h (7 days) maximum
- Default interval: 24h
- `--once` flag for immediate sync before watching
- Docker-friendly (works with restart=unless-stopped)

Files:
- cmd_watch.go: Watch command implementation
- cmd_watch_test.go: Tests for watch command
- cli.go: Register watch command
- cli_test.go: Update command count test
- README.md: Documentation for watch command

Tests: All passing
Lint: No issues
## Linting improvements
- Update .golangci.yml with AI-optimized settings
  - Add new linters: cyclop, nestif, maintidx, musttag, nilnil, prealloc, usestdlibvars
  - Tighten complexity limits: funlen 100 lines, gocyclo 15
  - Exclude test files from complexity checks
- Add lefthook.yml for Git hooks (pre-commit/pre-push checks)
- Add make install for one-command development tool setup
- Add make check to run all Git hooks checks manually

## Code quality fixes
- Fix usestdlibvars issues: replace "GET" with http.MethodGet (3 occurrences)
- Fix nilnil issues: replace return nil,nil with proper errors (3 occurrences)

## Refactoring to reduce cyclomatic complexity
- utils.go: Extract titleMatchingLevels helper functions
  - exactMatch, normalizedMatch, fuzzyMatch, levenshteinMatch
  - Reduce complexity from 37 to <15
- app.go: Extract updater creation helper functions
  - newAnimeUpdater, newMangaUpdater
  - newReverseAnimeUpdater, newReverseMangaUpdater
  - Reduce NewApp complexity from 28 to <15

## Documentation
- Update CLAUDE.md with AI agent development rules
- Add linting workflow, code complexity limits, and style rules

All checks pass: format ✓ imports ✓ vet ✓ lint (0 issues) ✓ tests ✓
- Add WatchConfig struct with GetInterval() method
- Update config.example.yaml with watch section
- Implement priority: CLI flag > Config > Error (no auto-default)
- Add comprehensive tests for interval priority
- Update README documentation

Priority order:
1. CLI --interval flag (highest)
2. watch.interval in config.yaml
3. Error if neither specified (no default)
Remove deprecated skip-tests option from cyclop linter settings,
which is no longer supported in golangci-lint v2.x. Test files
are already excluded via the exclusions section.

Also update project references to use v2.2.2 consistently.
- Update Dockerfile: golang:1.23-alpine → golang:1.25-alpine
- Update go.mod: go 1.24.0 → go 1.25.0
- Update go.mod: toolchain go1.24.5 → toolchain go1.25.5
- Run go mod tidy && go mod vendor

All tests pass after upgrade.
CI was using v2.2 which has compatibility issues with the config format.
Local environment uses v2.7.2 which works correctly.
@bigspawn
bigspawn merged commit 4a31227 into main Jan 7, 2026
3 checks passed
@bigspawn
bigspawn deleted the feature/watch-mode branch January 7, 2026 20:36
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.

Feature: Watch mode for scheduled sync

1 participant