MacNotesApp

repository·main·Indexed 43 days ago

https://github.com/rhettbull/macnotesapp

A Python-based interface and command-line tool for interacting with Apple macOS Notes.app. Version 0.8.2 allows developers to programmatically manage notes, accounts, and folders via a Python API (using the NotesApp class) or a CLI (invoked as `notes`) to add, list, edit, and delete notes from the terminal.

Tokens
9.1K
Snippets
47
Records
56
Agent score
54%

What's inside MacNotesApp

  1. Core classes in macnotesapp

    main

    The macnotesapp library provides a Python interface to Apple's Notes.app. The primary entry point is the NotesApp class, which manages the connection to the application. Other key classes include:

    • NotesApp: The main interface to Notes.app.
    • Account: Represents a specific Notes account (e.g., iCloud, On My Mac).
    • Folder: Represents a folder within a specific account.
    • Note: Represents an individual note.
    • NotesList: A collection of notes.
    • Attachment: Represents files attached to a note.
  2. Install MacNotesApp via pipx

    main

    To use the MacNotesApp command line interface (CLI) without manually managing Python virtual environments, install it using pipx. This installs the notes executable directly to your path.

    Prerequisites

    Ensure you have Homebrew installed on your macOS system.

    Installation Steps

    1. Install pipx using Homebrew:
      brew install pipx
    2. Install macnotesapp using pipx:
      pipx install macnotesapp
    3. Verify the installation by running the notes command:
      notes
    brew install pipx
    pipx install macnotesapp
    notes
  3. Install macnotesapp using uv

    main

    The recommended installation method is via the uv Python package manager.

    1. Install uv using the official script:
    curl -LsSf https://astral.sh/uv/install.sh | sh
    1. Install macnotesapp with Python 3.13:
    uv tool install --python 3.13 macnotesapp

    To upgrade the tool later, use:

    uv tool upgrade macnotesapp

    You can also run the tool without installing it using uv tool run --python 3.13 macnotesapp or uvx --python 3.13 macnotesapp.

    curl -LsSf https://astral.sh/uv/install.sh | sh
    uv tool install --python 3.13 macnotesapp
  4. Set up the development environment

    main

    MacNotesApp uses uv for dependency management. To set up a local development environment, synchronize the dependencies to create a virtual environment in .venv/.

    To execute commands within the environment, prefix them with uv run or activate the environment manually.

    # Create virtual environment and install dependencies
    uv sync
    
    # Run commands via uv
    uv run notes --help
    
    # Or activate manually
    source .venv/bin/activate
  5. Run tests with pytest

    main

    The test suite uses pytest. Warning: The tests are interactive and operate on your actual Notes.app data. Because they require user input, you must use the -s flag to prevent pytest from capturing stdout/stderr.

    uv run pytest -v -s tests/
  6. Install macnotesapp using Homebrew

    main

    For users on Apple Silicon (M1, etc.) Macs, you can install the CLI via Homebrew:

    1. Tap the repository:
    brew tap RhetTbull/macnotesapp https://github.com/RhetTbull/macnotesapp
    1. Update and install:
    brew update
    brew install macnotesapp

    After installation, the command is invoked using notes.

    Note: This method is not supported on Intel Macs; use the uv method instead.

    brew tap RhetTbull/macnotesapp https://github.com/RhetTbull/macnotesapp
    brew update
    brew install macnotesapp
  7. Build and deploy documentation with mkdocs

    main

    Documentation is maintained in the docs/ directory using mkdocs. You can build the documentation locally or deploy it directly to GitHub Pages.

    # Build documentation locally
    uv run mkdocs build
    
    # Deploy documentation to GitHub Pages
    uv run mkdocs gh-deploy
  8. Manage Notes with Account, Folder, Note, and NotesList

    main

    The macnotesapp package exports several core classes to model the hierarchy of Apple Notes:

    • Account: Represents a specific Notes account (e.g., iCloud, On My Mac).
    • Folder: Represents a folder within a specific account.
    • Note: Represents an individual note containing content and metadata.
    • NotesList: A collection of notes, typically returned by queries or account/folder lookups.
  9. How rich_click_echo works

    main

    The rich_click_echo function is a specialized wrapper around click.echo. It is designed to capture rich-formatted output (including Markdown and colors) into a buffer and then pass that buffer to click.echo.

    This ensures that even when using click's standard output mechanisms, the visual richness provided by the rich library is preserved. It automatically handles terminal width detection to prevent unwanted wrapping during tests or when outputting to non-terminal environments.