Skip to content

Latest commit

 

History

History
106 lines (79 loc) · 3.45 KB

README.org

File metadata and controls

106 lines (79 loc) · 3.45 KB

CLANSI

Installation

Add this to your leiningen `project.clj` depedencies

[com.bunimo/clansi "1.3.1-LPG-SNAPSHOT"]

…or to your deps.edn…

:deps {
    com.bunimo/clansi {:mvn/version "1.3.1-LPG-SNAPSHOT"}
}

Usage

ANSI colorization helper functions for Clojure programs.

You can call (clansi/style-test-page) to see what colors and styles are supported by your terminal.

Wrap strings in ANSI color and style codes like this:

(style "foo bar" :red)

(style "foo bar" :underline)

(style "foo bar" :blue :bg-red :underline)

You can turn the production of ANSI codes on or off by rebinding the clansi.core/*use-ansi* variable at runtime. This allows you to maintain only one version of your code with the strings marked up for color, and then turn ANSI on or off as desired, according to the properties of each output device, user preference, execution context, etc.

(without-ansi) and (with-ansi) convenience macros are provided for this purpose:

(defn print-colorized [] 
  (println (style "foo bar" :red)))

(print-colorized) ;; prints "foo bar" in red
(without-ansi (print-colorized)) ;; prints plain "foo bar", without any ANSI color codes
(without-ansi (with-ansi (print-colorized)) (print-colorized)) ;; prints a red "foo bar", then a plaintext "foo bar"

Deployment to Clojars

Update pom.xml

Link to original blog post

If no pom.xml exists use the following command to create it.

clojure -Spom

Once a pom.xml does exist, update the version in the file

Install the pack alias

Link to original blog post

Run the following command to add the :pack alias to you deps.edn file.

clojure -Sdeps '{:deps {pack/pack.alpha {:git/url "https://github.com/juxt/pack.alpha.git" :sha "dccf2134bcf03726a9465d2b9997c42e5cd91bff"}}}' -m mach.pack.alpha.inject 'c70740ffc10805f34836da2160fa1899601fac02'

Build your JAR

Link to original blog post

Use pack’s skinny jar mode to create a jar that’s suitable for upload to clojars.

clojure -A:pack mach.pack.alpha.skinny --no-libs --project-path clansi-1.3.1.jar

Release the JAR using Deps Deploy

Link to original blog post

Add a :deploy alias that uses the deps-deploy library

{:aliases
  {:deploy {:extra-deps {deps-deploy {:mvn/version "RELEASE"}}
            :main-opts ["-m" "deps-deploy.deps-deploy" "deploy" "clansi-1.3.1.jar"]}}
 }

Invoke the :deploy alias (NOTE: first line to exclude token from history)

export HISTFILE=/dev/null
CLOJARS_USERNAME=lgouger CLOJARS_PASSWORD=${CLOJARS_DEPLOYMENT_TOKEN} clojure -A:deploy

Bonus Features

call (clansi/colorize-docs) to make doc colorized

also supplies the color-doc macro, a stylized version of doc