Skip to main content

clerk

Interrogate docstring coverage pre-commit.ci status

Simple CLI to create new Markdown journal entry files.

Usage

$ journal
# Creates or re-opens today's journal

$ journal tomorrow
# Creates or re-opens tomorrow's journal

$ journal last friday
# Creates or re-opens last friday's journal

Installation

$ pipx install josephhaaga-clerk && pipx ensurepath

Setup

Create a .clerkrc file in your home directory that looks like the following, but fill in your own details. For example, here's mine!

[DEFAULT]
journal_directory=~/journals  # where your journals will be created
preferred_editor=vi  # or code, nano, emacs, babi
date_format=%%Y-%%m-%%d  # double % required - used in datetime's strftime()
file_extension=md  # or rst, txt

Note: ini files don't support comments; remove those!

Hooks

As of v0.0.2, you can add custom callback functions. Simply add the callback name in your .clerkrc, and ensure the package is installed!

For example, here's how you'd configure clerk-timestamp to fire every time you open a journal

[DEFAULT]
...

[hooks]
JOURNAL_OPENED =
    timestamp

Callback-specific configuration can be provided in a separate block in your .clerkrc config file (see clerk-timestamp example)

Custom Callback functions

Callback functions receive the entire journal document as a list of lines List[str], and can return their own List[str] of lines that will overwrite the document. (return None or False if you don't wish to make any changes)

Note that callback functions are called in the order they're listed, so in the following configuration, will receive the output of the first callback function. In the following example, timestamp receives the output of fortune-cookie

[DEFAULT]
...

[hooks]
NEW_JOURNAL_CREATED =
    fortune-cookie
    timestamp

Available Hooks

All hooks have the following interface

Input:

  • a Sequence[str] representing the lines in the journal document
  • a Mapping containing any user-provided configuration

Output: a List[str] representing the updated journal document (returning None or False will prevent any update)

New journal created

The NEW_JOURNAL_CREATED hook runs whenever the user opens a journal file that does not exist yet.

Journal opened

The JOURNAL_OPENED hook runs whenever the user opens a journal file.

Journal saved

The JOURNAL_SAVED hook runs whenever a user saves their journal (resulting in the file's md5 hash changing).

Journal closed

The JOURNAL_CLOSED hook runs whenever a user closes their journal.

Development

$ python3 -m pip install pytest pytest-cov pytest-xdist

# Re-run tests whenever a file is changed
$ PYTHONPATH=${PWD} python3 -m pytest -f

Release files for josephhaaga-clerk 0.0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for josephhaaga-clerk 0.0.12
File Size Uploaded
josephhaaga-clerk-0.0.12.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for josephhaaga-clerk 0.0.12
File Interpreter ABI Platform
josephhaaga_clerk-0.0.12-py3-none-any.whl Python 3 none any Details

Total release size: 12.4 kB

Release files / josephhaaga-clerk-0.0.12.tar.gz

Download URL josephhaaga-clerk-0.0.12.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a72aa86bf2956cbea32b60ed6b1527c200c73c892bcd022df3ed1c886c5b43a7
BLAKE2b-256 checksum
How to use checksums
021be0e308b933c3017654f4af4b33b1d3576c4d864a6bdc9ceeed846cd3ec69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / josephhaaga_clerk-0.0.12-py3-none-any.whl

Download URL josephhaaga_clerk-0.0.12-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d002a827c44df66de3a2a048a666f970000d857e2c8fbbb7fee5b50763c9cbe9
BLAKE2b-256 checksum
How to use checksums
83074be68cd51aed8bc1c1ec304d5f2dba00d048e7123810ea7a0b730fa4d99c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release history Release notifications | RSS feed

This release

0.0.12 This release

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page