mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Update hello lune example
This commit is contained in:
parent
f1296e391b
commit
16d9c94822
4 changed files with 47 additions and 23 deletions
|
@ -14,19 +14,35 @@ module.sayHello()
|
|||
--[==[
|
||||
EXAMPLE #2
|
||||
|
||||
Using the stdio library to prompt for input
|
||||
]==]
|
||||
|
||||
local text = stdio.prompt("text", "Please write some text")
|
||||
print("You wrote '" .. text .. "'!\n")
|
||||
|
||||
local confirmed = stdio.prompt("confirm", "Please confirm that you wrote some text")
|
||||
if confirmed == false then
|
||||
error("You didn't confirm!")
|
||||
else
|
||||
print("Confirmed!")
|
||||
end
|
||||
|
||||
--[==[
|
||||
EXAMPLE #3
|
||||
|
||||
Using arguments given to the program
|
||||
]==]
|
||||
|
||||
if #process.args > 0 then
|
||||
print("\nGot arguments while running hello_lune:")
|
||||
console.log(process.args)
|
||||
print(process.args)
|
||||
if #process.args > 3 then
|
||||
error("Too many arguments!")
|
||||
end
|
||||
end
|
||||
|
||||
--[==[
|
||||
EXAMPLE #3
|
||||
EXAMPLE #4
|
||||
|
||||
Spawning tasks
|
||||
]==]
|
||||
|
@ -46,7 +62,7 @@ task.delay(5, function()
|
|||
end)
|
||||
|
||||
--[==[
|
||||
EXAMPLE #4
|
||||
EXAMPLE #5
|
||||
|
||||
Get & set environment variables
|
||||
|
||||
|
@ -67,7 +83,7 @@ for key, value in process.env do
|
|||
end
|
||||
|
||||
--[==[
|
||||
EXAMPLE #5
|
||||
EXAMPLE #6
|
||||
|
||||
Read files in the current directory
|
||||
|
||||
|
@ -110,7 +126,7 @@ end
|
|||
-- since the ping command does not work in azure
|
||||
if not process.env.GITHUB_ACTIONS then
|
||||
--[==[
|
||||
EXAMPLE #6
|
||||
EXAMPLE #7
|
||||
|
||||
Call out to another program / executable
|
||||
|
||||
|
@ -125,7 +141,7 @@ if not process.env.GITHUB_ACTIONS then
|
|||
})
|
||||
|
||||
--[==[
|
||||
EXAMPLE #7
|
||||
EXAMPLE #8
|
||||
|
||||
Using the result of a spawned process, exiting the process
|
||||
|
||||
|
@ -152,7 +168,7 @@ if not process.env.GITHUB_ACTIONS then
|
|||
end
|
||||
|
||||
--[==[
|
||||
EXAMPLE #8
|
||||
EXAMPLE #9
|
||||
|
||||
Using the built-in networking library
|
||||
]==]
|
||||
|
@ -189,19 +205,17 @@ assert(apiResponse.body == "bar", "Invalid json response")
|
|||
print("Got valid JSON response with changes applied")
|
||||
|
||||
--[==[
|
||||
EXAMPLE #9
|
||||
EXAMPLE #10
|
||||
|
||||
Using the console library to print pretty
|
||||
Using the stdio library to print pretty
|
||||
]==]
|
||||
|
||||
print("\nPrinting with pretty colors and auto-formatting 🎨")
|
||||
|
||||
console.setColor("blue")
|
||||
print(string.rep("—", 22))
|
||||
console.resetColor()
|
||||
print(stdio.color("blue") .. string.rep("—", 22) .. stdio.color("reset"))
|
||||
|
||||
console.info("API response:", apiResponse)
|
||||
console.warn({
|
||||
info("API response:", apiResponse)
|
||||
warn({
|
||||
Oh = {
|
||||
No = {
|
||||
TooMuch = {
|
||||
|
@ -213,12 +227,10 @@ console.warn({
|
|||
},
|
||||
})
|
||||
|
||||
console.setColor("blue")
|
||||
print(string.rep("—", 22))
|
||||
console.resetColor()
|
||||
print(stdio.color("blue") .. string.rep("—", 22) .. stdio.color("reset"))
|
||||
|
||||
--[==[
|
||||
EXAMPLE #10
|
||||
EXAMPLE #11
|
||||
|
||||
Saying goodbye 😔
|
||||
]==]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
local module = {}
|
||||
|
||||
function module.sayHello()
|
||||
print("\nHello from a module! 🧩")
|
||||
print("\nHello from a module! 🧩\n")
|
||||
end
|
||||
|
||||
return module
|
||||
|
|
|
@ -347,11 +347,16 @@
|
|||
"name": "color"
|
||||
}
|
||||
],
|
||||
"returns": []
|
||||
"returns": [
|
||||
"@roblox/global/stdio.color/return/0"
|
||||
]
|
||||
},
|
||||
"@roblox/global/stdio.color/param/0": {
|
||||
"documentation": "The color to use"
|
||||
},
|
||||
"@roblox/global/stdio.color/return/0": {
|
||||
"documentation": "A printable ANSI string"
|
||||
},
|
||||
"@roblox/global/stdio.ewrite": {
|
||||
"code_sample": "",
|
||||
"documentation": "Writes a string directly to stderr, without any newline.",
|
||||
|
@ -426,11 +431,16 @@
|
|||
"name": "style"
|
||||
}
|
||||
],
|
||||
"returns": []
|
||||
"returns": [
|
||||
"@roblox/global/stdio.style/return/0"
|
||||
]
|
||||
},
|
||||
"@roblox/global/stdio.style/param/0": {
|
||||
"documentation": "The style to use"
|
||||
},
|
||||
"@roblox/global/stdio.style/return/0": {
|
||||
"documentation": "A printable ANSI string"
|
||||
},
|
||||
"@roblox/global/stdio.write": {
|
||||
"code_sample": "",
|
||||
"documentation": "Writes a string directly to stdout, without any newline.",
|
||||
|
|
|
@ -305,8 +305,9 @@ declare stdio: {
|
|||
```
|
||||
|
||||
@param color The color to use
|
||||
@return A printable ANSI string
|
||||
]=]
|
||||
color: (color: "reset" | "black" | "red" | "green" | "yellow" | "blue" | "purple" | "cyan" | "white") -> (),
|
||||
color: (color: "reset" | "black" | "red" | "green" | "yellow" | "blue" | "purple" | "cyan" | "white") -> string,
|
||||
--[=[
|
||||
@within stdio
|
||||
|
||||
|
@ -324,8 +325,9 @@ declare stdio: {
|
|||
```
|
||||
|
||||
@param style The style to use
|
||||
@return A printable ANSI string
|
||||
]=]
|
||||
style: (style: "reset" | "bold" | "dim") -> (),
|
||||
style: (style: "reset" | "bold" | "dim") -> string,
|
||||
--[=[
|
||||
@within stdio
|
||||
|
||||
|
|
Loading…
Reference in a new issue