Next Generation Shell

A modern programming language for DevOps

About

Next Generation Shell is a modern programming language that focuses on "DevOps"y use cases.

NGS utilizes a subset of bash syntax for running external programs and provides additional facilities for ergonomic experience: exit codes handling, output parsing, etc.

Data manipulation is convenient. NGS provides map, filter and other primitives for basic functional programming, uniquely extended to support patterns.

Examples and Sample Features

Standard library instead of repetative re-implementation in each script.
  • log("my log message")
  • debug("facility", "closing file ${f}") and run with DEBUG=facility environment variable
  • status("Reading ${f} - ${p}% done")
  • retry function
Run external programs ergonomically
  • $(your_program --id $id --values $*values)
  • p=$(your_program &) ... p.kill()
  • output = `your_program --values $*args`
  • structured_data = ``curl https://api.example.com/blah.json``
  • smart and customizable handling of processes' exit codes (including throwing exceptions)
Manipulate structured data
  • map, filter, reject with the usual meanings
  • mapk - maps hash keys
  • mapv - maps hash values
  • filterk / rejectk - filters hash by keys
  • filterv / rejectv - filters hash by values
  • the_one - returns the only element in an array
  • group - groups values into hash
  • collector - accumulates result
  • Table - displays tabular data elegantly
  • Stats - counts occurrences
  • fetch - reads and parses a file or a URL
More examples at RosettaCode

Links

Install

Curl

curl https://ngs-lang.org/install.sh | bash

Git

git clone git@github.com:ngs-lang/ngs.git
cd ngs && ./install.sh

Homebrew

brew install ngs

Snap

sudo snap install ngs

Jupyter Notebook


!curl "https://raw.githubusercontent.com/ngs-lang/ngs-ipython-extension/master/ngs-install.sh" | bash

%load_ext ngs
%ngs [single line expression]
%%ngs [multi line code]

Run Without Installing

Docker

docker run -it --rm ngslang/ngs

Docker with Jupyter Notebook

docker run -p 8888:8888 ngslang/ngs-jupyter

Github Actions

- uses: ngs-lang/ngs@v0.2.13
- run: ngs -pi 'sum(10..100)'

powered bybeame.io logo