Skip to main content

A CLI to manage daily journal entries

Project description

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

Setup

Create a .clerkrc file in your home directory 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!

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.

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.7.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

josephhaaga_clerk-0.0.7-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: josephhaaga-clerk-0.0.7.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for josephhaaga-clerk-0.0.7.tar.gz
Algorithm Hash digest
SHA256 a20792b434d98253efa982e3d3440a0d2998cf04e369044db2bc0c6296eb6a89
MD5 6d85a2814752b193f91f1e7109b304bc
BLAKE2b-256 68caaa4300989924ae32a764ed5f42b0cb11704eb08cf754cf7ad5d1521cae41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for josephhaaga_clerk-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 3f7d8fd01972a2399c95916ca1848967e27a963ef6993c8045823280fa82d086
MD5 8b31537befa4f163540b0d918e62765a
BLAKE2b-256 e16de23f266c36df180ef928a1b1ffb97cc8063d0eeeb3c8ebf25ff7931f7836

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