Non-interactive nREPL client for shell scripts and command-line

Overview

nreplops-tool (nr)

nreplops-tool (nr) is a non-interactive nREPL client designed to be used in shell scripts and on the command-line.

Early α warning: This project is still at a very early development phase. While the tool is probably reasonably usable (and the author uses it daily) the current development focus is not on quality, stability, or documentation.

Try it out in 1 minute

This example assumes you are able to install packages with Homebrew. See the Installation section below for other options.

Start by installing nreplops-tool (nr) and Babashka (bb):

brew install mjhanninen/sour/nreplops-tool borkdude/brew/babashka

Launch a Babashka nREPL server (that listens on the port 1667 by default):

bb nrepl-server

Open another terminal and evaluate an expression with nr:

nr -p 1667 -e '(println "Hello, world!")'

Quick examples

Before starting make sure that you have a Clojure nREPL server running in the background and there is a corresponding .nrepl-port file in either the current working directory or any of its ancestor.

Evaluate the expression (+ 1 2) on a nREPL server:

$ nr -e '(+ 1 2)'
3

Pass the expressions through a pipe:

$ echo '(+ 1 2)' | nr
3

Evaluate the content of a file:

$ echo '(+ 1 2)' > plus.clj
$ nr plus.clj
3

Create an executable nREPL scripts:

$ cat <<EOF > plus.nrepl
+ #!/usr/bin/env nr -!
+ (+ 1 2)
+ EOF
$ chmod +x plus.nrepl
$ ./plus.nrepl
3

Suppose the nREPL server had a function called get-user-by-email that searched in retrieved users from the application database by email. A script exposing that functionality to the command line could look something like this:

$ cat <<EOF > get-user-by-email.nrepl
+ #!/usr/bin/env nr -! --no-results
+ (clojure.pprint/pprint
+   (get-user-by-email db "#nr[1]"))
$ EOF
$ chmod +x get-user-by-email.nrepl
$ ./get-user-by-email.nrepl [email protected]
{:name "Wile E. Coyote"
 :email "[email protected]"
 :phone "555-555 555"}

Installation

Homebrew

brew install mjhanninen/sour/nreplops-tool

Cargo

cargo install nreplops-tool

Building from sources

git clone https://github.com/mjhanninen/nreplops-tool.git
cargo install --path .

Goals

  • Easy of use in shell scripts
  • Consistency and interoperability with Babashka and jq

License

Copyright 2022 Matti Hänninen

Licensed under the Apache License 2.0

Please see the LICENSE and NOTICE files.

You might also like...
A command line interface meant to bridge the gap between Rust and shell scripting

clawbang A command line interface meant to bridge the gap between Rust and shell scripting. Intended for use with HEREDOCs and shebangs: $ clawbang

A command-line shell like fish, but POSIX compatible.
A command-line shell like fish, but POSIX compatible.

A command-line shell like fish, but POSIX compatible.

Command-line HTTP client for sending a POST request to specified URI on each stdin line.

line2httppost Simple tool to read lines from stdin and post each line as separate POST request to a specified URL (TCP connection is reused though). G

Small command-line tool to switch monitor inputs from command line

swmon Small command-line tool to switch monitor inputs from command line Installation git clone https://github.com/cr1901/swmon cargo install --path .

Configurable, extensible, interactive line reader

linefeed linefeed is a configurable, concurrent, extensible, interactive input reader for Unix terminals and Windows console. API Documentation linefe

A small, interactive command runner
A small, interactive command runner

Dotree is a small interactive command runner. It wants to be a better home for your aliases and bash functions, especially those that you don't use th

A CLI tool for CIs and build scripts, making file system based caching easy and correct (locking, eviction, etc.)

FS Dir Cache A CLI tool for CIs and build scripts, making file system based caching easy and correct (locking, eviction, etc.) When working on build s

REC2 (Rusty External Command and Control) is client and server tool allowing auditor to execute command from VirusTotal and Mastodon APIs written in Rust. 🦀
REC2 (Rusty External Command and Control) is client and server tool allowing auditor to execute command from VirusTotal and Mastodon APIs written in Rust. 🦀

Information: REC2 is an old personal project (early 2023) that I didn't continue development on. It's part of a list of projects that helped me to lea

Shellharden is a syntax highlighter and a tool to semi-automate the rewriting of scripts to ShellCheck conformance, mainly focused on quoting
Shellharden is a syntax highlighter and a tool to semi-automate the rewriting of scripts to ShellCheck conformance, mainly focused on quoting

Shellharden is a syntax highlighter and a tool to semi-automate the rewriting of scripts to ShellCheck conformance, mainly focused on quoting

Releases(v0.0.10)
Owner
Matti Hänninen
Matti Hänninen
A command-line tool for patching shell scripts inspired by resholve

patsh A command-line tool for patching shell scripts inspired by resholve nix run github:nix-community/patsh -- -f script.sh Usage Usage: patsh [OPTIO

Nix community projects 23 Jan 7, 2023
Self-contained template system with Handlebars and inline shell scripts

Handlematters Self-contained template system with Handlebars and inline shell scripts Introduction Handlematters is a template system that combines Ha

Keita Urashima 3 Sep 9, 2022
Quickly save and retrieve values for shell scripts.

Quickly save and retrieve values for shell scripts.

Alex Andrade 2 Dec 15, 2022
Shellcheck - a static analysis tool for shell scripts

ShellCheck - A shell script static analysis tool ShellCheck is a GPLv3 tool that gives warnings and suggestions for bash/sh shell scripts: The goals o

Vidar Holen 31.1k Jan 9, 2023
An interactive shell environment for exploring the p2panda protocol

An interactive shell environment for exploring the p2panda protocol. Uses a mock node and clients to simulate network logic.

null 4 Dec 12, 2021
An interactive cheatsheet tool for the command-line

navi An interactive cheatsheet tool for the command-line. navi allows you to browse through cheatsheets (that you may write yourself or download from

Denis Isidoro 12.2k Dec 30, 2022
Coinlive is an interactive command line tool that displays live cryptocurrency prices.

Coinlive is an interactive command line tool that displays live cryptocurrency prices. It can also display simple historical price charts.

Mayer Analytics 9 Dec 7, 2022
ruborute is an interactive command-line tool to get asphyxia@sdvx gaming data.

ruborute Are you 暴龍天 ?. The ruborute is an interactive command-line tool to get asphyxia@sdvx gaming data. asphyxia-core/plugins: https://github.com/a

RinChanNOW! 9 Sep 28, 2022
A toolkit for building your own interactive command-line tools in Rust

promkit A toolkit for building your own interactive command-line tools in Rust, utilizing crossterm. Getting Started Put the package in your Cargo.tom

null 70 Dec 18, 2022
Application microframework with command-line option parsing, configuration, error handling, logging, and shell interactions

Abscissa is a microframework for building Rust applications (either CLI tools or network/web services), aiming to provide a large number of features w

iqlusion 524 Dec 26, 2022