Metadata-Version: 2.4
Name: jps-crontab-utils
Version: 0.1.0
Summary: Collection of Python utilities for inspecting and searching crontab.
Author-email: Jaideep Sundaram <jai.python3@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/jai-python3/jps-crontab-utils
Project-URL: Repository, https://github.com/jai-python3/jps-crontab-utils
Project-URL: Issues, https://github.com/jai-python3/jps-crontab-utils/issues
Keywords: cookiecutter,bootstrap,project-generator,automation
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typer>=0.12.3
Provides-Extra: test
Requires-Dist: pytest>=8.0.0; extra == "test"
Provides-Extra: dev
Requires-Dist: flake8>=7.0.0; extra == "dev"
Requires-Dist: black>=24.0.0; extra == "dev"
Requires-Dist: build>=1.2.1; extra == "dev"
Requires-Dist: twine>=5.0.0; extra == "dev"
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-mock>=3.15.1; extra == "dev"
Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
Requires-Dist: isort>=5.13.0; extra == "dev"
Requires-Dist: codecov>=2.1.13; extra == "dev"
Requires-Dist: autoflake>=2.3.1; extra == "dev"
Requires-Dist: pre-commit>=3.8.0; extra == "dev"
Requires-Dist: bandit>=1.7.9; extra == "dev"
Requires-Dist: vulture>=2.11; extra == "dev"
Requires-Dist: flynt>=1.0.1; extra == "dev"
Requires-Dist: pydocstyle>=6.3.0; extra == "dev"
Requires-Dist: darglint>=1.8.1; extra == "dev"
Requires-Dist: mypy>=1.12.1; extra == "dev"
Dynamic: license-file

# jps-crontab-utils

![Build](https://github.com/jai-python3/jps-crontab-utils/actions/workflows/test.yml/badge.svg)
![Publish to PyPI](https://github.com/jai-python3/jps-crontab-utils/actions/workflows/publish-to-pypi.yml/badge.svg)
[![codecov](https://codecov.io/gh/jai-python3/jps-crontab-utils/branch/main/graph/badge.svg)](https://codecov.io/gh/jai-python3/jps-crontab-utils)

Collection of Python utilities for parsing, validating, and searching crontab files.

## 🚀 Overview

`jps-crontab-utils` provides three command-line tools:

### **1. Crontab Parser**
Parses raw crontab files into structured job objects:

- Supports per-job metadata via comment blocks  
- Handles multiline commands with POSIX `\` continuation  
- Resolves executables using `$PATH` or absolute paths  
- Normalizes metadata keys automatically (`owner-email` → `owner_email`)

### **2. Crontab Checker**
Validates each cron job for:

- Required metadata (owner, owner email, reference, repository, etc.)
- Recommended metadata (labels, run frequency, description, etc.)
- Executable existence, file type, +x bit, and non-empty status  
- Outputs human-readable tables **or JSON for automation**

### **3. Crontab Search Utility**
Queries crontab entries based on:

- Labels (`--label nightly`)
- Owner email (`--email john.smith`)
- Code repository (`--repo git@gitlab.com:org/pipeline.git`)
- Full JSON output for programmatic analysis

These utilities help improve crontab hygiene, enforce team standards, and identify broken or undocumented jobs across large environments.

---

## Features

- 🔍 **Search** cron jobs using metadata filters  
- 📝 **Parse** job schedule, command, metadata  
- 🛠 **Validate** executables and metadata completeness  
- 📈 **Rich terminal tables** (typer + rich)  
- 📦 **JSON output** for CI/CD and automation  
- 🧪 **100% test-covered parser and search modules**

---

## Example Usage

#### **Parse and inspect a crontab**

```bash
jps-crontab-parse --file /etc/crontab
```
Search for jobs labeled “nightly”

```bash
jps-crontab-search --file crontab.txt --label nightly
```

Audit a crontab

```bash
jps-crontab-check --file crontab.txt
```

JSON mode for pipelines

```bash
jps-crontab-check --file crontab.txt --json | jq .
```

## 📦 Installation

```bash
make install
```

```bash
pip install jps-crontab-utils
```


## 🧪 Development

```bash
make fix && make format && make lint
make test
```


## 📜 License
MIT License © Jaideep Sundaram

## Documentation

📘 Full documentation: see docs/USAGE.md
