Quickstart
How to get Sprig up and running by building the executable
Setting up Sprig is straight forward. Let's get it working on your machine:
You'll need to have the following installed on your machine:
node: the runtime Sprig works in
npm: to install dependencies
pkg: to package Sprig into an executable
Once you've installed the above dependencies, you're ready to get started.
Clone the repo and install the dependencies:
git clone https://github.com/dibsonthis/sprig.git
cd sprig
npm install
Use the following command to build the Sprig executable - this compiles and packages sprig into the bin
folder:
npm run package // for Mac
npm run package:win // for Windows
You can use the executable you just created directly from the bin
folder (or wherever you choose to move it to). But it's preferable to install the compiled executable globally so you can call sprig
from anywhere:
npm run bin // for Mac
npm run bin:win // for Windows
If you want to build and install Sprig in one go, you can use this script:
npm run deploy // for Mac
npm run deploy:win // for Windows
That's it! You should now have a fully functional Sprig executable ready to go.
Your first Sprig program
What kind of programming guide would this be if it didn't include a Hello World example? Let's write your first Sprig program and run it using the executable we just built.
Create a file called hello.sp
and write the following Sprig code inside of it:
const sayHello = (name = "Jack") => "hello world, my name is {{name}}"->print
sayHello()
To run the above program, simply run this command in your terminal (assuming you've followed the step to install Sprig globally, and that you're in the directory of the hello.sp
file):
sprig hello.sp
You should see the following output:
hello world, my name is Jack
Hooray 🎉 You've now written and ran your first Sprig program. Well done!
A deeper look at Sprig features
Head over to the next section to get an understanding of Sprig basics and what features are available for you to play around with.
Last updated