I made a J.D. Javascript CLI

Dunno how useful this is for y’all, since I mostly just built it for myself, but I made a Johnny Decimal CLI using Deno! I also created a system for making Javascript plugins for it, so that it can be extended for more specific usecases. I’ve been using it for the past few months, so I think it’s mostly pretty stable at this point.

CLI Guide: https://johnny.bpev.me

Code: github.com/ivebencrazy/johnny_decimal

You can also import the javascript modules for any other javascript project you’re working on.

2 Likes

:heart_eyes: Been thinking about doing something similar myself – using Deno – for ages, but never got round to it. 100% will be checking this out on the weekend, thanks for posting!

1 Like

Cool! And yupyup it took me a while to get around to it as well heh. Kinda wish I had tried building it in Rust, but I liked the idea of exporting a lot of the non-basic functionality as a Javascript/Typescript plugin system. Maybe I can try turning it into a hybrid app at some point… :thinking:

O ya I forgot to put a plugin code link in the parent, but if you start thinking about writing some code, there are some plugin examples I made for myself (also, all the included commands are written as “plugins” as well).

1 Like

The CLI didn’t work for me with the Fish shell, so I wrote up a little Fish script to handle this.

function jd
  set -l JD_HOME $HOME/Documents
  set -l SEARCH $argv[1]

  if string match -rq '^(?<category>[0-9]{2})$' $SEARCH
    # Matches category regex: `dd`. Navigate to category
    set -l CATEGORY (find -E $JD_HOME -regex ".*/$SEARCH .*" -depth 2 -type d) 2>/dev/null;

    test -z "$CATEGORY" && cd $JD_HOME && return 1
    cd $CATEGORY
  else if string match -rq '^(?<category>[0-9]{2})\.(?<id>[0-9]{2,4})$' $SEARCH
    # Matches id regex: `dd.dd`. Navigate to id
    set -l CATEGORY (find -E $JD_HOME -regex ".*/$category .*" -depth 2 -type d) 2>/dev/null;
    set -l ID (find -E $CATEGORY -regex ".*/$id ?.*" -type d ) 2>/dev/null;

    test -z "$ID" && cd $JD_HOME && return 1

    cd $ID
  else
    # No arg for cd. Navigate to root.
    cd $JD_HOME 2>/dev/null;
  end
end

Can’t get it to play nice with the existing jd commands though.

2 Likes