Update hello lune example

This commit is contained in:
Filip Tibell 2023-02-06 13:10:52 -05:00
parent f1296e391b
commit 16d9c94822
No known key found for this signature in database
4 changed files with 47 additions and 23 deletions

View file

@ -14,19 +14,35 @@ module.sayHello()
--[==[ --[==[
EXAMPLE #2 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 Using arguments given to the program
]==] ]==]
if #process.args > 0 then if #process.args > 0 then
print("\nGot arguments while running hello_lune:") print("\nGot arguments while running hello_lune:")
console.log(process.args) print(process.args)
if #process.args > 3 then if #process.args > 3 then
error("Too many arguments!") error("Too many arguments!")
end end
end end
--[==[ --[==[
EXAMPLE #3 EXAMPLE #4
Spawning tasks Spawning tasks
]==] ]==]
@ -46,7 +62,7 @@ task.delay(5, function()
end) end)
--[==[ --[==[
EXAMPLE #4 EXAMPLE #5
Get & set environment variables Get & set environment variables
@ -67,7 +83,7 @@ for key, value in process.env do
end end
--[==[ --[==[
EXAMPLE #5 EXAMPLE #6
Read files in the current directory Read files in the current directory
@ -110,7 +126,7 @@ end
-- since the ping command does not work in azure -- since the ping command does not work in azure
if not process.env.GITHUB_ACTIONS then if not process.env.GITHUB_ACTIONS then
--[==[ --[==[
EXAMPLE #6 EXAMPLE #7
Call out to another program / executable 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 Using the result of a spawned process, exiting the process
@ -152,7 +168,7 @@ if not process.env.GITHUB_ACTIONS then
end end
--[==[ --[==[
EXAMPLE #8 EXAMPLE #9
Using the built-in networking library 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") 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 🎨") print("\nPrinting with pretty colors and auto-formatting 🎨")
console.setColor("blue") print(stdio.color("blue") .. string.rep("", 22) .. stdio.color("reset"))
print(string.rep("", 22))
console.resetColor()
console.info("API response:", apiResponse) info("API response:", apiResponse)
console.warn({ warn({
Oh = { Oh = {
No = { No = {
TooMuch = { TooMuch = {
@ -213,12 +227,10 @@ console.warn({
}, },
}) })
console.setColor("blue") print(stdio.color("blue") .. string.rep("", 22) .. stdio.color("reset"))
print(string.rep("", 22))
console.resetColor()
--[==[ --[==[
EXAMPLE #10 EXAMPLE #11
Saying goodbye 😔 Saying goodbye 😔
]==] ]==]

View file

@ -1,7 +1,7 @@
local module = {} local module = {}
function module.sayHello() function module.sayHello()
print("\nHello from a module! 🧩") print("\nHello from a module! 🧩\n")
end end
return module return module

View file

@ -347,11 +347,16 @@
"name": "color" "name": "color"
} }
], ],
"returns": [] "returns": [
"@roblox/global/stdio.color/return/0"
]
}, },
"@roblox/global/stdio.color/param/0": { "@roblox/global/stdio.color/param/0": {
"documentation": "The color to use" "documentation": "The color to use"
}, },
"@roblox/global/stdio.color/return/0": {
"documentation": "A printable ANSI string"
},
"@roblox/global/stdio.ewrite": { "@roblox/global/stdio.ewrite": {
"code_sample": "", "code_sample": "",
"documentation": "Writes a string directly to stderr, without any newline.", "documentation": "Writes a string directly to stderr, without any newline.",
@ -426,11 +431,16 @@
"name": "style" "name": "style"
} }
], ],
"returns": [] "returns": [
"@roblox/global/stdio.style/return/0"
]
}, },
"@roblox/global/stdio.style/param/0": { "@roblox/global/stdio.style/param/0": {
"documentation": "The style to use" "documentation": "The style to use"
}, },
"@roblox/global/stdio.style/return/0": {
"documentation": "A printable ANSI string"
},
"@roblox/global/stdio.write": { "@roblox/global/stdio.write": {
"code_sample": "", "code_sample": "",
"documentation": "Writes a string directly to stdout, without any newline.", "documentation": "Writes a string directly to stdout, without any newline.",

View file

@ -305,8 +305,9 @@ declare stdio: {
``` ```
@param color The color to use @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 @within stdio
@ -324,8 +325,9 @@ declare stdio: {
``` ```
@param style The style to use @param style The style to use
@return A printable ANSI string
]=] ]=]
style: (style: "reset" | "bold" | "dim") -> (), style: (style: "reset" | "bold" | "dim") -> string,
--[=[ --[=[
@within stdio @within stdio