Skip to content
Dewayne VanHoozer edited this page Jul 4, 2022 · 21 revisions

justprep ...

... is a ore-processor to CLI task runners such as JUST. It provides the ability to include other task definition file's content into your main task file invoked by a set of keyword directives that you define. It also adds a short-hand way of specifying modules that are accessible from your main task file. The module provides the concept of a sub-task.

Configuration

justprep is configured using System Environment Variables

  • JUSTPREP_FOR identifies the task runner to be targeted.
  • JUSTPREP_KEYWORDS specifies the inclusionary keywords that you want to use.
  • JUSTPREP_MODULE_KEYWORD also allows you to specify the keyword that defines a module
  • JUSTPREP_FILENAME_IN defines the basename of files to look for that contain justprep keywords.
  • JUSTPREP_FILENAME_OUT defines the basename of the file that justprep creates from its input files. Typically this value is "justfile" which is the default of the just program.

Installation

There are two implementations of justprep available. The Ruby Gem version and the compiled Crystal version. See Ruby And Crystal for some details.

The Ruby Gem version should be able to run on any platform that has Ruby installed.

Why two implementations? Is there a performance difference? I can't tell if there is any speed difference between the two. It there is it is so small its not worth mentioning.

The reason there are two implementation are 1) I'm researching automatic conversion of Ruby source code into compilable Crystal code; and 2) some organizations which use just are not (shutter) using Ruby. Did I really call them dinosaurs?

Quick aside. For CPU intensive tasks, the compiled Crystal versions of some of my simple Ruby projects is over 30 times faster than their Ruby prototypes.

As a Ruby Gem

justprep is a command line utility. There is no need to include it in a Gemfile. Just do:

gem install justprep

Crystal Binary Implementation

MacOS

The simplest way on a MacOS platform is to use brew

brew install --build-from-source MadBomber/tap/justprep

Or you could download the latest release. See the [Precompiled Binaries] section below.

Compile Crystal Implementation from Source

Clone or fork the repository and compile.

Easiest way to compile the Crystal implementation is using the JUST utility. You do have just installed right?

From the repository root (RR) directory do:

just build

This will build both the Ruby gem implementation and the Crystal implementation. If you only want to build the Crystal version do:

cd crystal
just build

Other useful tasks are available in the justfile supplied with the repository. To see a list of those recipes just(sic) do:

just

Precompiled Binaries

Binary releases are available. They are currently compiled for macos and linux (on the x86_64 architecture.)

You should be able to download the binaries and use them directly.

# Download the matching binary from https://github.com/MadBomber/justprep/releases/latest
$ chmod a+x justprep-*
$ mv justprep-* ~/.bin/justprep # or other appropriate directory

Useful Shell Alias

I use the bash shell and JUST. I have a bash alise jj defined. It executes justprep and then just like this:

alias jj='justprep && just --no-dotenv'

I use the program direnv which defines environment variables via a .envrc file whenever I cd into a directory. That is why I use the "--no-dotenv" option for the just program.

... and yes. I use the Crystal implementation of justprep rather than the Ruby gem implementation even though they are both the same. See Ruby And Crystal for details on why there are two implementations.

Check out the Examples

Sometimes in my examples of things I will use a Ruby or shell script in the task definitions. These can usually be found in my scripts repo.

Clone this wiki locally