Skip to main content

A CLI to manage daily journal entries

Project description

clerk

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

Setup

Create a clerk.conf file that looks like the following, but fill in your own details

[DEFAULT]
journal_directory=/Users/josephhaaga/journals  # absolute path
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!

Then, move the config file to your app directory

$ mv clerk.conf $(python3 -c "import clerk.config; print(clerk.config.dirs().user_config_dir)")

Hooks

As of v0.0.2, you can add custom callback functions. Simply add the callback name in your clerk.conf, 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 clerk.conf 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.

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

josephhaaga-clerk-0.0.3.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

josephhaaga_clerk-0.0.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file josephhaaga-clerk-0.0.3.tar.gz.

File metadata

  • Download URL: josephhaaga-clerk-0.0.3.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for josephhaaga-clerk-0.0.3.tar.gz
Algorithm Hash digest
SHA256 13ae4393588f5b7b1996caff019d86806f985697ee239b891fd1f3f2a96efc33
MD5 a145fdbe06099e8b460d7ba144c87936
BLAKE2b-256 dcdac1a3fd0d9c437168d4cddc1699a7594da0c6446526b16df39ae0d30111d4

See more details on using hashes here.

File details

Details for the file josephhaaga_clerk-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: josephhaaga_clerk-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for josephhaaga_clerk-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 643020ae5a99f3ea64d1ea62c3ea549312b98d605973e7fce79b40953e027c42
MD5 273c67d7021622e3272bde92a1737bc7
BLAKE2b-256 44cc41b06752599e35b56eab724e2ac20d7bb2bc1f98294d6f05b8c4f2c9e450

See more details on using hashes here.

Supported by

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