Skip to content

Command Line

Jude Payne edited this page Apr 21, 2024 · 11 revisions

You can install dictim as a command line tool directly without needing to have downloaded this project or required it as a dependency.

Prerequisites

  1. install babshka the awesome Clojure scripting runtime.

  2. install bbin the script installation tool for babashka.

Installation Instructions

In your terminal run

bbin install https://github.com/judepayne/dictim/releases/latest/download/dictim.jar

That's it!

Try

dictim -h

to see the help.

If the dictim script generated by bbin is not found, then it's probable that the folder where bbin stores scripts ~/.local/bin has not been put on your path by bbin and you may need to add it manually in your ~/.zprofile (or similar).

Installation without bbin

If you're not using bbin, you'll still need babashka installed and will need to build dictim.jar

Clone the dictim repo locally, cd into it and run

bb build

This will build a dictim.jar in the repo folder which you can run by

bb dictim.jar -h

(to see the help)

Using the dictim command line tool

Here's the help of the dictim tool

  -c, --compile Compiles supplied dictim to d2
                The value supplied to --compile may be either
                  - a edn string (in single quotes)
                  - a file containing edn. Prefix the file name with '@'
                  - ommitted in which case stdin is read
		  
  -p, --parse   Parses supplied d2 into dictim
                The value supplied to --parse may be either
                  - a d2 string (in single quotes)
                  - a file containing d2. Prefix the file name with '@'
                  - ommitted in which case *std-in* is read
                --parse has various supplemental flags:
      --k       Convert keys to keywords when parsing d2 to dictim syntax edn
      --j       Converts the output of parse to dictim syntax json
      --b       Additional to  -j: prettifies the json output of parse
      
  -v, --version Returns the version of dictm
  
  -h, --help    Displays this help

The main functions are --compile (or -c) and --parse (or -p)

Compile

Compile accepts either a string, or a file name that should be prefixed with the @ character, or if you omit the argument then standdard in is read.

Examples at the terminal command line:

$ dictim -c '["John" "Manager"] ["Pauli" "Developer"] ["John" "->" "Pauli" "I wish I still had your job"]'
John: Manager

hmm, where did the other dictim expressions go? The command line tool expects either a single expression or a sequence of expression, so let's put them in a list. Using a list for this purpose is recommended because Edn's list notation () is not used anywhere in the dictim syntax.

$ dictim -c '(["John" "Manager"] ["Pauli" "Developer"] ["John" "->" "Pauli" "I wish I still had your job"])'
John: Manager
Pauli: Developer
John -> Pauli: I wish I still had your job

If you feed this to d2 and then on to a file

dictim -c '(["John" "Manager"] ["Pauli" "Developer"] ["John" "->" "Pauli" "I wish I still had your job"])' | d2 - >> out.svg

(the d2 tool uses - to represent stdin and stdout.

You'll get an svg image like this

Clone this wiki locally