starlight-cli 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,49 +1,49 @@
1
- # Starlight Language
1
+
2
+ # Starlight Programming Language
2
3
 
3
4
  Starlight is a lightweight, developer-oriented programming language designed for **server-side scripting, automation, and general-purpose programming**. It combines a clean, readable syntax inspired by JavaScript and Python with powerful runtime features such as async/await, modules, and interactive I/O.
4
5
 
5
- **Official Reference:** [https://starlight-learn-lang.pages.dev/](https://starlight-learn-lang.pages.dev/)
6
+ **Official Reference:**
7
+ https://starlight-learn-lang.pages.dev/
6
8
 
7
9
  ---
8
10
 
9
11
  ## Key Features
10
12
 
11
- * **Modern, Simple Syntax** – Familiar to JavaScript and Python developers
12
- * **Async / Await** – Native support for asynchronous operations
13
- * **Modules & Imports** – Import JavaScript packages or other `.sl` files
14
- * **Server-side Ready** – Built on Node.js, ideal for backend logic
15
- * **Interactive I/O** – Built-in `ask` and `sldeploy`
16
- * **Built-in Utilities** – `sleep`, `len`, `keys`, `values`, `fetch`, `get`, `post`
13
+ - **Modern, Simple Syntax** – Familiar to JavaScript and Python developers
14
+ - **Async / Await** – Native support for asynchronous operations
15
+ - **Modules & Imports** – Import JavaScript packages or other `.sl` files
16
+ - **Server-side Ready** – Built on Node.js, ideal for backend logic
17
+ - **Interactive I/O** – Built-in `ask` and `sldeploy`
18
+ - **Built-in Utilities** – `sleep`, `len`, `keys`, `values`, `fetch`, `get`, `post`
17
19
 
18
20
  ---
19
21
 
20
22
  ## Installation
21
23
 
22
24
  1. Install **Node.js** (v18+ recommended)
23
- 2. Install Starlight CLI:
25
+ 2. Install the Starlight CLI:
24
26
 
25
- ```
27
+ ```bash
26
28
  npm install -g starlight-cli
27
- ```
29
+ ````
28
30
 
29
31
  ---
30
32
 
31
33
  ## Your First Program (`hello.sl`)
32
34
 
33
- ```
35
+ ```sl
34
36
  let name = ask("What is your name?")
35
37
  sldeploy "Hello, " + name + "!"
36
38
  ```
37
39
 
38
40
  Run:
39
41
 
40
- ```
42
+ ```bash
41
43
  starlight hello.sl
42
44
  ```
43
45
 
44
- ---
45
-
46
- ## Output
46
+ ### Output
47
47
 
48
48
  ```
49
49
  What is your name? Alice
@@ -56,7 +56,7 @@ Hello, Alice!
56
56
 
57
57
  ### Variables
58
58
 
59
- ```
59
+ ```sl
60
60
  let x = 10
61
61
  let text = "hello"
62
62
  ```
@@ -65,7 +65,7 @@ let text = "hello"
65
65
 
66
66
  ### Functions
67
67
 
68
- ```
68
+ ```sl
69
69
  func add(a, b) {
70
70
  return a + b
71
71
  }
@@ -73,9 +73,11 @@ func add(a, b) {
73
73
  sldeploy add(2, 3)
74
74
  ```
75
75
 
76
+ ---
77
+
76
78
  ### Async Functions
77
79
 
78
- ```
80
+ ```sl
79
81
  async func load() {
80
82
  let data = await get("https://example.com/api")
81
83
  sldeploy data
@@ -86,208 +88,144 @@ load()
86
88
 
87
89
  ---
88
90
 
89
- ## Conditionals
90
-
91
- ```
92
- if (x > 5) {
93
- sldeploy "Greater than 5"
94
- } else {
95
- sldeploy "5 or less"
96
- }
97
- ```
91
+ ## Arrow Functions
98
92
 
99
- ---
100
-
101
- ## Loops
93
+ Arrow functions provide a **concise and expressive** way to define functions.
102
94
 
103
- ### While Loop
95
+ ### Basic Arrow Function
104
96
 
105
- ```
106
- let i = 0
107
- while (i < 3) {
108
- sldeploy i
109
- i = i + 1
110
- }
97
+ ```sl
98
+ let square = x => x * x
99
+ sldeploy square(5)
111
100
  ```
112
101
 
113
- ---
102
+ ### Multiple Parameters
114
103
 
115
- ### For Loop (C-style)
116
-
117
- ```
118
- for (let i = 0; i < 3; i = i + 1) {
119
- sldeploy i
120
- }
104
+ ```sl
105
+ let add = (a, b) => a + b
106
+ sldeploy add(10, 20)
121
107
  ```
122
108
 
123
- ---
124
-
125
- ### For-In Loop (Python-style)
126
-
127
- Iterate over arrays:
109
+ ### Block Body with if / else
128
110
 
129
- ```
130
- let items = ["apple", "banana", "orange"]
131
-
132
- for item in items {
133
- sldeploy item
111
+ ```sl
112
+ let label = p => {
113
+ if (p.price > 1000) {
114
+ return "Premium"
115
+ } else {
116
+ return "Standard"
117
+ }
134
118
  }
135
119
  ```
136
120
 
137
- With `let` (scoped variable):
121
+ ### Arrow Functions with Objects
138
122
 
139
- ```
140
- for let item in items {
141
- sldeploy item
123
+ ```sl
124
+ let summarize = p => {
125
+ return {
126
+ "name": p.name,
127
+ "value": p.price * p.stock
128
+ }
142
129
  }
143
130
  ```
144
131
 
145
- Iterate over object keys:
146
-
147
- ```
148
- let user = { "name": "Alice", "age": 20 }
149
-
150
- for key in user {
151
- sldeploy key + ": " + user[key]
152
- }
153
- ```
132
+ Arrow functions capture their surrounding scope and behave like standard functions while remaining lightweight and readable.
154
133
 
155
134
  ---
156
135
 
157
- ## Objects & Arrays
136
+ ## Conditionals
158
137
 
159
- ```
160
- let product = {
161
- "name": "Star Lamp",
162
- "price": 50,
163
- "tags": ["space", "light"]
138
+ ```sl
139
+ if (x > 5) {
140
+ sldeploy "Greater than 5"
141
+ } else {
142
+ sldeploy "5 or less"
164
143
  }
165
-
166
- sldeploy product
167
144
  ```
168
145
 
169
146
  ---
170
147
 
171
- ## sldeploy (Output)
172
-
173
- `sldeploy` works like Python's `print` and can display **any type**:
174
-
175
- ```
176
- sldeploy 42
177
- sldeploy "hello"
178
- sldeploy true
179
- sldeploy [1, 2, 3]
180
- sldeploy { "a": 1, "b": 2 }
181
- ```
182
-
183
- It automatically formats arrays, objects, functions, and nested values.
184
-
185
- ---
148
+ ## Loops
186
149
 
187
- ## ask (User Input)
150
+ ### While Loop
188
151
 
189
- ```
190
- let age = ask("Enter your age:")
191
- sldeploy "You entered: " + age
152
+ ```sl
153
+ let i = 0
154
+ while (i < 3) {
155
+ sldeploy i
156
+ i = i + 1
157
+ }
192
158
  ```
193
159
 
194
160
  ---
195
161
 
196
- ## Modules & Imports
197
-
198
- ### Import JavaScript Packages
162
+ ## Start & Race Statements
199
163
 
200
- ```
201
- import colors from "starlight-color"
164
+ Starlight includes a **start / race** control structure similar to a switch statement, with **fall-through behavior**.
202
165
 
203
- sldeploy colors.blue("Hello Starlight")
204
- ```
166
+ ### Syntax
205
167
 
206
- ### Import Local Files
168
+ ```sl
169
+ start (value) {
170
+ race (1) {
171
+ # body
172
+ }
207
173
 
174
+ race (2) {
175
+ # body
176
+ }
177
+ }
208
178
  ```
209
- import { add } from "./math.sl"
210
- ```
211
-
212
- ---
213
-
214
- ## Built-in Utilities
215
179
 
216
- * `len(value)` – length of array, string, or object
217
- * `keys(object)` – object keys
218
- * `values(object)` – object values
219
- * `sleep(ms)` – async delay
220
- * `fetch(url)` – low-level fetch
221
- * `get(url)` – GET request
222
- * `post(url, data)` – POST request
223
- * `num(value)` – convert to number
224
- * `str(value)` – convert to string
225
-
226
- ---
180
+ ### Example
227
181
 
228
- ## Server-side Example
182
+ ```sl
183
+ define x = 2
229
184
 
230
- ```
231
- define server = async () => {
232
- let response = await get("https://jsonplaceholder.typicode.com/todos/1")
233
- sldeploy response
185
+ start (x) {
186
+ race (1) { sldeploy("Race 1 executed") }
187
+ race (2) { sldeploy("Race 2 executed") }
188
+ race (3) { sldeploy("Race 3 executed") }
234
189
  }
235
190
 
236
- server()
191
+ sldeploy("Done with start statement")
237
192
  ```
238
193
 
239
- ---
240
- ## Start & Race Statements
241
-
242
- Starlight includes a **`start` / `race`** control structure similar to JavaScript `switch`, with **fall-through behavior**. The `start` statement evaluates a discriminant expression and executes all `race` clauses **starting from the first match** until the end, unless a `break` is used.
243
-
244
- ### Syntax
194
+ ### Expected Output
245
195
 
246
196
  ```
247
- start (<discriminant>) {
248
- race (<value>) {
249
- # body
250
- }
251
-
252
- race (<value>) {
253
- # body
254
- }
255
-
197
+ Race 2 executed
198
+ Race 3 executed
199
+ Done with start statement
256
200
  ```
257
201
 
202
+ ---
258
203
 
204
+ ## Markdown Preview (`starlight filename.md`)
259
205
 
260
- - `start` evaluates the discriminant expression.
261
- - `race` – each clause is checked; execution starts at the first matching `race` and continues to subsequent races (fall-through).
262
- - Optional `break` can stop execution early (if implemented).
206
+ Starlight can also be used to **preview Markdown files** directly from the CLI.
263
207
 
264
- ### Example
208
+ ### Usage
265
209
 
210
+ ```bash
211
+ starlight README.md
266
212
  ```
267
- define x = 2;
268
213
 
269
- start (x) {
270
- race (1) { sldeploy("Race 1 executed"); }
271
- race (2) { sldeploy("Race 2 executed"); }
272
- race (3) { sldeploy("Race 3 executed"); }
273
- }
214
+ ### How It Works (Execution Flow)
274
215
 
275
- sldeploy("Done with start statement");
276
-
277
- ```
216
+ 1. The CLI detects the `.md` file extension
217
+ 2. The Markdown file is read from disk
218
+ 3. Markdown is converted to HTML using a full-featured Markdown renderer
219
+ 4. A **temporary HTML file** is created in the system temp directory
220
+ 5. The file is opened in your default browser using `file://`
221
+ 6. After the browser loads, the temporary file is **automatically deleted**
278
222
 
279
- **Expected Output:**
223
+ This makes Starlight useful not only as a programming language, but also as a **developer productivity tool**.
280
224
 
281
- ```
282
- Race 2 executed
283
- Race 3 executed
284
- Done with start statement
225
+ ---
285
226
 
286
- ```
287
227
  ## Why Starlight?
288
228
 
289
- Starlight is designed for developers who want:
290
-
291
229
  * A **simple but powerful** scripting language
292
230
  * **Fast server-side automation**
293
231
  * Familiar syntax with **less boilerplate**
@@ -295,7 +233,11 @@ Starlight is designed for developers who want:
295
233
 
296
234
  ---
297
235
 
298
- 📘 Full documentation and tutorials:
299
- [https://starlight-learn-lang.pages.dev/](https://starlight-learn-lang.pages.dev/)
236
+ ## License
237
+
238
+ MIT License
239
+
240
+ ---
300
241
 
301
- **License:** MIT
242
+ ## Author and Developer
243
+ Dominex Macedon