Installation
Install the Starlight CLI globally using npm:
npm install -g starlight-cli@latest
Getting Started
Starlight is a Python/JavaScript hybrid scripting language. Here's a simple example:
// Hello World in Starlight
let greeting = "Hello, Starlight!";
sldeploy(greeting);
Variables
Declare variables using let and optionally assign values:
let x = 10;
let name = "Dominex";
let flag = true;
Functions
Define regular and async functions:
// Regular function
func add(a, b) {
return a + b;
}
// Async function
async func fetchData(url) {
let response = await fetch(url);
return await response.json();
}
Arrow Functions
Starlight supports concise arrow function syntax:
let square = x => x * x;
sldeploy(square(5)); // 25
Conditionals
Supports if, else if, and else:
let x = 15;
if x > 10 {
sldeploy("x is greater than 10");
} else {
sldeploy("x is 10 or less");
}
Loops
Starlight has Python-style and C-style loops:
// Python-style
for let i in range(5) {
sldeploy(i);
}
// C-style
for (let i = 0; i < 5; i++) {
sldeploy(i);
}
while x > 0 {
sldeploy(x);
x--;
}
Special Statements
Starlight includes:
sldeploy– Prints formatted output:
sldeploy { "name": "Dominex", "score": 100 }
doTrack– Error handling (like try/catch):
do {
riskyOperation();
} track {
sldeploy(error);
}
ask– Get user input:
let name = ask("Enter your name:");
sldeploy("Hello " + name);
Imports
Import modules using JavaScript-like syntax:
import fs from "fs";
import { readFile, writeFile as save } from "./utils.sl";
import * as helpers from "./helpers.sl";
Built-in Functions
len(obj)– Returns length of string, array, or object keyssldeploy(value)– Prints a valuetype(value)– Returns typekeys(obj),values(obj)– Object keys and valuesrange(start, end, step)– Creates array of numbersask(prompt)– User inputnum(value)– Converts to numberstr(value)– Converts to stringfetch(url),get(url),post(url, data)– HTTP requestssleep(ms)– Pause execution asynchronously
Objects and Arrays
let arr = [1, 2, 3];
let obj = { "name": "Dominex", "score": 100 };
sldeploy(arr[0]); // 1
sldeploy(obj.name); // Dominex
Example Program
let scores = [10, 20, 30];
for let s in scores {
if s > 15 {
sldeploy(s + " is high!");
} else {
sldeploy(s + " is low!");
}
}
async func main() {
let data = await fetch("https://api.example.com/data");
sldeploy(data);
}
main();
License & Author
Developed by Dominex Macedon. For installation, use:
npm install -g starlight-cli@latest