Starish: python-like shell scripting, based on the Starlark langugage.
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
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
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
Pull the latest release:
docker pull kassybas/starish
Or copy starish to your Docker image:
COPY --from=kassybas/starish /starish /usr/local/bin/starish
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.
Written in Go, distributed as a single binary, it requires no packages or libraries to be installed on the system.
The python-like syntax makes the scripts familiar, accessible and easily readable, by minimizing boilerplate.
Using the load
function, you can import other starish (or starlark) files.
load("./docker.star", "docker")
docker.build(img, path)
With interactive shell (REPL) starish has the ability to execute each command one by one for testing and development.
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
""")
TODO
-
Starlark README: starlark-readme.md
-
Language definition: doc/spec.md
-
About the Go implementation: doc/impl.md
-
API documentation: godoc.org/go.starlark.net/starlark
-
Mailing list: starlark-go
-
Issue tracker: https://github.com/google/starlark-go/issues