Skip to content

Commit

Permalink
Update hello lune example
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptibell committed Feb 6, 2023
1 parent f1296e3 commit 16d9c94
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 23 deletions.
48 changes: 30 additions & 18 deletions .lune/hello_lune.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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
]==]
Expand All @@ -46,7 +62,7 @@ task.delay(5, function()
end)

--[==[
EXAMPLE #4
EXAMPLE #5
Get & set environment variables
Expand All @@ -67,7 +83,7 @@ for key, value in process.env do
end

--[==[
EXAMPLE #5
EXAMPLE #6
Read files in the current directory
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -152,7 +168,7 @@ if not process.env.GITHUB_ACTIONS then
end

--[==[
EXAMPLE #8
EXAMPLE #9
Using the built-in networking library
]==]
Expand Down Expand Up @@ -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 = {
Expand All @@ -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 😔
]==]
Expand Down
2 changes: 1 addition & 1 deletion .lune/modules/module.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local module = {}

function module.sayHello()
print("\nHello from a module! 🧩")
print("\nHello from a module! 🧩\n")
end

return module
14 changes: 12 additions & 2 deletions luneDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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.",
Expand Down
6 changes: 4 additions & 2 deletions luneTypes.d.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 16d9c94

Please sign in to comment.