Skip to content

python-like shell scripting, based on the Starlark language

License

Notifications You must be signed in to change notification settings

kassybas/starish

 
 

Repository files navigation

Starish

Starish: python-like shell scripting, based on the Starlark langugage.

Travis CI

Quickstart

Create a Starfile

name = "World"
# Variables in scope are injected as variables to shell
sh('echo "Hello ${name}"')
# output: "Hello World"

See more on the sh function below.

Run in the same working directory

starish

Call a function directly from CLI

# ./Starfile
def foo():
  print("Hello foo")
$ starish foo
# output: "Hello foo"

Start in interactive mode with flag -i

$ starish -i

Install

MacOS

curl -Lo /usr/local/bin/starish https://github.com/kassybas/starish/releases/download/0.2.2/starish_amd64_darwin_0.2.2
chmod +x /usr/local/bin/starish

Linux

curl -Lo /usr/local/bin/starish https://github.com/kassybas/starish/releases/download/0.2.2/starish_amd64_linux_0.2.2
chmod +x /usr/local/bin/starish

Docker

Pull the latest release:

docker pull kassybas/starish

Or copy starish to your Docker image:

COPY --from=kassybas/starish /starish /usr/local/bin/starish

Why

The purpose of starish is to provide a readable and extenadble way to run scripts locally, . It is not intended to be a general purpose programming language but rather glue code for the small bits of automations which are usually placed in shell scripts or Makefiles.

Goals

Portable interpreter

Written in Go, distributed as a single binary, it requires no packages or libraries to be installed on the system.

Readable

The python-like syntax makes the scripts familiar, accessible and easily readable, by minimizing boilerplate.

Reusable

Using the load function, you can import other starish (or starlark) files.

load("./docker.star", "docker")
docker.build(img, path)

Interactive shell

With interactive shell (REPL) starish has the ability to execute each command one by one for testing and development.

Shell integration

The main extension of starish is the special sh() function, which makes it possbile to interact with starish variables in the invoked shell scripts.

The captured the stdout, stderr and status code is returned.

foo = "bar"
out, err, rc = sh("""
  echo "hello world" >&2
  echo "${foo}"
  exit 42
""")

Command line integration

TODO

Complex variables

Starlark vs Starish

Documentation of the Starlark language

About

python-like shell scripting, based on the Starlark language

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.9%
  • Other 0.1%