Skip to content

lainiwa/buglog

Repository files navigation

Tests Code Coverage Maintainability Docs

BUGlog - log what's bugging you

This CLI tool is meant to be used as

  • pills intake log
  • pain diary
  • anxiety/CBT diary
  • calorie counter
  • and whatever else

Note: the project is pre-alpha quality.

Rationale

Install

Any of these would go:

pip install --user 'git+https://github.com/lainiwa/buglog'

pipx install 'git+https://github.com/lainiwa/buglog'  # newer versions

pipx install --spec 'git+https://github.com/lainiwa/buglog.git' buglog

Then the util can be run as:

bug

Upon the first invocation the tool will automatically

  • download fzf binary
  • and create a template configuration at ~/.config/buglog/config.py

Usage

At it's current design the bug command does not accept any arguments. Just execute it an you will see the list of the "bugs" you can log into your personal log/database.

Choose a few with Tab and press Enter. You will see a reStructuredText document where you are expected to type in some parameters of the bug. Fill in the gaps and save and exit the editor.

Then you will be prompted with a dialog, which will lead you to a time picker. The time you enter can be either in a machine-like format (ex.: 2020-07-21_10:51:10) or in a human readable (say today at 4:20).

All in all, your bugs will be finally saved in the ~/.local/share/buglog/ directory in a format YYYY-MM-DD_hh:mm:ss_BugClassName.json.

Currently there is no way to use the data with the means of buglog itself. However, you can use bash scripting and jq to mess with the saved data.

Configuration

The configuration file is read from ${XDG_CONFIG_HOME:-${HOME}/.config}/buglog/config.py. In case no such file exists, buglog will automatically create it from the template configuration.

The configuration file -- exclusive of imports -- consists of flat Pydantic classes, inherited from Bug model.

Take a look at the example Bug below:

class Squats(Bug):
    """Excercise: squats"""
    reps: int = Field(1, title="Repetitions", gt=0)
    times: int = Field(..., gt=0)

Let's now line by line. First of all, to create a new Bug we need to derive it from the Bug class, so that buglog would know it is a Bug and not something else.

class Squats(Bug):

Not the docstring part here is completeley optional. You can choose not to write one, if it feels like the class name is informative enough.

"""Excercise: squats"""

The title is also not strictly required: it is used as a more verbose description compared to a name of the field.

The type int of the field will be checked against and enforced.

reps: int = Field(1, title="Repetitions", gt=0)

The first positional argument if the Field() is the default. If you do not want the field to have a default -- you should put ... instead.

Use can specify additional checkers, for example gt=0 means the filed should be greater-than zero.

Limitations

Similar Projects

  • Taskwarrior: is centered around TODO-based workflow (AFAIK. It's rather complex)
  • Dijo: ???
  • Habitctl: the idea is quiet similar, although the bugs/habits are not parameterized
  • Watson: a time tracker
  • Org mode: using Emacs' Org mode to track habits

License

Buglog is released under the MIT License. See the bundled LICENSE file for details.