Skip to content

spro/hashpipe

Repository files navigation

hashpipe

Hashpipe is an experimental JSON-based shell. Imagine that Bash was designed for manipulating web APIs instead of a filesystem.

Try it in your browser →

Featuring:

  • JSON-typed input & output (strings, numbers, objects, and arrays)
  • Alternative piping constructs (like the parallel pipe ||, sequential pipe |=, and error pipe |?)
  • First-class functions (lambda literals like {| * 2 } and named commands via def)
  • Modular design (use modules to unlock namespaced commands like http.get and files.cat)

Getting started

Installation

$ npm install -g hashpipe
$ hashpipe
#|

At a glance

Bash-like command pipelines

#| use files
#| files.cat names.txt | split '\n' | match John | sort
[ 'John Adams',
  'John King',
  'John Lee',
  'John Mitchell' ]

Parallel and series pipes to map commands over arrays

#| [1, 3, 4, 12] || * 5
[ 5, 15, 20, 60 ]

#|  echo john jacob jingleheimer | split ' ' || upper
[ 'JOHN', 'JACOB', 'JINGLEHEIMER' ]

Special @ syntax for traversing JSON objects and arrays

#| ['a', 'b', 'c'] @ 0
'a'

#| {name: "George", age: 55} @ name
'George'

#| [{name: "Fred"}, {name: "Jerry"}, {name: "Tim"}] @ :name
[ 'Fred', 'Jerry', 'Tim' ]

Lambdas and named functions for reusable pipelines

#| [1, 2, 3] | map {| * 2 }
[ 2, 4, 6 ]

#| def dog-years { $n | $n * 7 }
#| dog-years 6
42

#| 6 | dog-years
42

Designed for easy interaction with JSON APIs

#| use http
#| http.get https://api.github.com/repos/spro/hashpipe @ {name, language, stars: stargazers_count}
{ name: 'hashpipe', language: 'TypeScript', stars: ... }

Learning more

Start with the core docs:

Then try one of the Hashpipe walkthroughs to see it in action:

Extending hashpipe

Commands are plain functions with a (inp, args, ctx, cb) signature, and modules are TypeScript files that export them. The module-author guide covers the contract, namespacing, async commands, and accepting lambdas.

About

Bash-like language and shell with parallel pipes and JSON support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors