Skip to main content

Simple CLI to catch sleep, view stats, and export data

Project description

zcatcher (sleep tracker)

A simple Python CLI to record sleep entries and view stats.

Installation

No external dependencies required. Ensure you have Python 3.8+.

Install from source (editable for development):

python -m pip install -e .

This installs the zcatcher console command.

Install with pipx (isolated):

pipx install .

If you already installed and pull new changes:

pipx reinstall zlog

Publish to PyPI

Build and check distributions:

python3 -m pip install build twine
python3 -m build
python3 -m twine check dist/*

Upload using a PyPI token (recommended):

export TWINE_USERNAME=__token__
export TWINE_PASSWORD="pypi-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
python3 -m twine upload dist/*

Alternatively, configure ~/.pypirc and omit env vars.

GitHub Actions (CI Publish)

This repo includes a workflow to publish on GitHub Release:

  • Workflow: .github/workflows/publish.yml
  • Trigger: publishing a GitHub Release or manual Run workflow
  • Requires a repository secret: PYPI_API_TOKEN

Steps to enable:

  1. Create a PyPI token with project scope (or scoped to an org).
  2. In your repo, add a secret: Settings → Secrets and variables → Actions → New repository secret
  • Name: PYPI_API_TOKEN
  • Value: your token (e.g., pypi-XXXXXXXX...)
  1. Create and publish a GitHub Release for the version (e.g., v0.3.0).
  • The workflow builds sdist/wheel and uploads to PyPI.

To use TestPyPI instead, edit the workflow step to set:

    - name: Publish to PyPI
      uses: pypa/gh-action-pypi-publish@release/v1
      with:
       password: ${{ secrets.PYPI_API_TOKEN }}
       repository-url: https://test.pypi.org/legacy/

Usage

Record a new entry (interactive prompts):

zcatcher

View stats (all data):

zcatcher --stats

Limit stats to last N days (e.g., 7):

zcatcher --stats --days 7

Output all data as a table:

zcatcher --data

Output all data as JSON:

zcatcher --json

Output all data as CSV to stdout:

zcatcher --csv

Use a custom data file path:

zcatcher --file /path/to/my_sleep.jsonl --stats

Help

  • Version: zcatcher --version displays the installed version.
  • Interactive entry: zcatcher prompts for sleep time, sleep difficulty, wake time, wake difficulty, and wake date.
  • Stats: zcatcher --stats shows averages; add --days N to limit the window.
  • Table: zcatcher --data prints all records in a table (excludes created_at).
  • JSON: zcatcher --json prints a JSON array of all records.
  • CSV: zcatcher --csv prints CSV with headers.
  • Custom data path: zcatcher --file /path/to/file.jsonl uses a specific file.

Data Storage

  • Records are stored as JSON Lines in ~/.zcatcher/sleep_data.jsonl by default (or a custom path via --file).
  • Each record includes:
    • sleep_date, sleep_time
    • wake_date, wake_time
    • difficulty_sleep (1-5), difficulty_wake (1-5)
    • duration_hours (computed)
    • created_at

Notes

  • Times can be 24-hour HH:MM or HHMM (colon optional).
  • Prompts now ask in order: sleep time, sleep difficulty, wake time, wake difficulty, then wake date (defaults to today if left blank).
  • If the sleep time is later than the wake time (e.g., 23:00 -> 07:00), the sleep date is assumed to be the previous day.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zcatcher-0.4.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zcatcher-0.4.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file zcatcher-0.4.0.tar.gz.

File metadata

  • Download URL: zcatcher-0.4.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for zcatcher-0.4.0.tar.gz
Algorithm Hash digest
SHA256 618c2593142cd4b7c37c0dceed9f20fea781a4f152a00092fb2eb9bf35002b3b
MD5 03bc1cbde6a0c6db37680f0bcdb8ca9c
BLAKE2b-256 15f772de885f0f6821819c1c3c513a430c0c510e6b5641edeea48b7cb0882b10

See more details on using hashes here.

File details

Details for the file zcatcher-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: zcatcher-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for zcatcher-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a2727bf34f92f61fe70d167432a10245c5f26844f65b9d2e9dcad8ecd9cf63a
MD5 1da093ec167c6873e803f158306f3ebd
BLAKE2b-256 ae6949b3bb41e431130ec670b70b4a420ab6cf193733f30c729a04f4e0bcc723

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page