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.3.0.tar.gz (17.8 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.3.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for zcatcher-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9b8ed7783e3c8655331022fd5248ae7f3c5b0b86627a1841062c777ccb55b297
MD5 96aa8011740cf8fb346e701919b9cc87
BLAKE2b-256 07acc280d599f37408a7436d45935af36cb46388e26470ff500d57d7149bb177

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zcatcher-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 18.3 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6136a8fc58db447d11955a3757ddf141054d68d275910f206a8a17d9567c712b
MD5 7b009fbb3a3ef1e26f8620981f746b91
BLAKE2b-256 09e7c7248950d8701309c5e493892296fa3c99ba326df388e12bb1bbb173f835

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