Snail is a SDK for displaying rich content in the Snail Terminal.
- Download the Snail Terminal
- Install Snail SDK into your project
npm i snail-sdk
pip install snail-sdk
The Snail SDK can display web content inline in the snail terminal. First create a .js file
document.body.textContent = 'Hello World!';
snail.setHeight(document.body.offsetHeight);
Then use the sdk to display the .js file
const { display } = require('snail-sdk');
display(require.resolve('./web.js'));
from pathlib import Path
from snail_sdk import display
display(Path(__file__).parent / "web.js")
const data = await snail.waitForMessage();
document.body.textContent = `${data.greeting} ${data.name}!`;
snail.setHeight(document.body.offsetHeight);
Then use the sdk to display the .js file and send it a message.
const { display, send } = require('snail-sdk');
display(require.resolve('./web.js'));
send({ name: 'Joel', greeting: 'Hey' });
from pathlib import Path
from snail_sdk import display, send
display(Path(__file__).parent / "web.js")
send({ 'name': 'Joel', 'greeting': 'Hey' })
Snail's progress bars won't distrupt other text from your program. They stick in place no matter how many times they are updated. And you can see their status in the app icon.
const { setProgress } = require('snail-sdk');
setProgress({ progress: 0.3, leftText: 'left', rightText: 'right'});
from snail_sdk import set_progress
set_progress(0.3, left_text="left", right_text="right")
Charts will appear inline in the terminal and update in real time.
const { chart } = require('snail-sdk');
for (let i = 0; i < 100; i++)
chart({ foo: Math.sin(i/10) });
from snail_sdk import chart
import math
for i in range(100):
chart({ 'foo': math.sin(i/10) })
When displaying web content, there is a global snail
object which communicates with the terminal.
Waits for any returns any value sent from the send
method in the sdk.
Sets the height of the web content. This must be called with a non-zero value in order for the web content be visible when not fullscreen.
Set's the web content to take up the whole terminal screen. Fullscreen content will automatically close if the program which displayed that content closes.
Sends some data over stdin which could be read by the controlling program.
Remove the web content from the terminal