type checking
This commit is contained in:
@ -1,26 +1,18 @@
|
|||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
local color_map = {
|
local function rainbowify(message: string): string
|
||||||
[1] = TERMINAL.OUT.STYLE.RED,
|
local parsed_terminal_message: {string} = {}
|
||||||
[2] = TERMINAL.OUT.STYLE.YELLOW,
|
local color_map = {
|
||||||
[3] = TERMINAL.OUT.STYLE.GREEN,
|
TERMINAL.OUT.STYLE.RED,
|
||||||
[4] = TERMINAL.OUT.STYLE.BLUE,
|
TERMINAL.OUT.STYLE.YELLOW,
|
||||||
[5] = TERMINAL.OUT.STYLE.MAGENTA,
|
TERMINAL.OUT.STYLE.GREEN,
|
||||||
}
|
TERMINAL.OUT.STYLE.BLUE,
|
||||||
|
TERMINAL.OUT.STYLE.MAGENTA,
|
||||||
|
}
|
||||||
|
|
||||||
local function rainbowify(message)
|
for i, char in message:split('') do
|
||||||
local iter = 1
|
table.insert(parsed_terminal_message, char ~= ' ' and color_map[i%5+1](char) or char)
|
||||||
local parsed_terminal_message = {}
|
|
||||||
|
|
||||||
for _, char in message:split('') do
|
|
||||||
local styled = char
|
|
||||||
if char ~= ' ' then
|
|
||||||
styled = color_map[iter%5+1](char)
|
|
||||||
iter += 1
|
|
||||||
end
|
end
|
||||||
table.insert(parsed_terminal_message, styled)
|
|
||||||
end
|
|
||||||
|
|
||||||
return table.concat(parsed_terminal_message)
|
return table.concat(parsed_terminal_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,18 +5,16 @@ type class_constructor<CON, F, EXT = {}> = {
|
|||||||
__index: CON,
|
__index: CON,
|
||||||
new: F,
|
new: F,
|
||||||
} & EXT
|
} & EXT
|
||||||
type class_method<Self, R, T...> = (self: Self, T...) -> R
|
|
||||||
|
|
||||||
type map<V, K = string> = {
|
|
||||||
[K]: V
|
|
||||||
}
|
|
||||||
type lambda<T...> = (f: (T...) -> ()) -> ()
|
|
||||||
type map_functions = {
|
type map_functions = {
|
||||||
len: () -> number,
|
len: () -> number,
|
||||||
len_keys: () -> number,
|
len_keys: () -> number,
|
||||||
len_values: () -> number,
|
len_values: () -> number,
|
||||||
for_each: lambda<string, string>
|
for_each: lambda<string, string>
|
||||||
}
|
}
|
||||||
|
type func_map<T, A...> = (A...) -> T
|
||||||
|
type class_method<Self, R, T...> = (self: Self, T...) -> R
|
||||||
|
type map<V, K = string> = {[K]: V}
|
||||||
|
type lambda<T...> = (f: (T...) -> ()) -> ()
|
||||||
--------------------------------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------------------------------
|
||||||
--------------------------------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------------------------------
|
||||||
type SHELL = {
|
type SHELL = {
|
||||||
@ -51,23 +49,26 @@ type SHELL = {
|
|||||||
}
|
}
|
||||||
--------------------------------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------------------------------
|
||||||
--------------------------------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------------------------------
|
||||||
type color<T> = (string) -> T
|
-- type text_on_foreground = {
|
||||||
type colors = {
|
-- ON_RED: func_map<string>,
|
||||||
RED: color<string>,
|
-- ON_ORANGE: func_map<string>,
|
||||||
ORANGE: color<string>,
|
-- ON_YELLOW: func_map<string>,
|
||||||
YELLOW: color<string>,
|
-- ON_GREEN: func_map<string>,
|
||||||
GREEN: color<string>,
|
-- ON_BLUE: func_map<string>,
|
||||||
BLUE: color<string>,
|
-- ON_PURPLE: func_map<string>,
|
||||||
PURPLE: color<string>
|
-- }
|
||||||
}
|
type text_colors = {
|
||||||
type text_style = {
|
RED: func_map<string, string>,
|
||||||
STYLE: {
|
ORANGE: func_map<string, string>,
|
||||||
BACKGROUND: colors,
|
YELLOW: func_map<string, string>,
|
||||||
FOREGROUND: colors
|
GREEN: func_map<string, string>,
|
||||||
}
|
BLUE: func_map<string, string>,
|
||||||
|
PURPLE: func_map<string, string>,
|
||||||
}
|
}
|
||||||
type TERMINAL = {
|
type TERMINAL = {
|
||||||
TEXT: text_style
|
OUT: {
|
||||||
|
STYLE: text_colors,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------------------------------
|
||||||
--------------------------------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -104,7 +105,9 @@ local SHELL = {} :: SHELL
|
|||||||
local TERMINAL = {} :: TERMINAL
|
local TERMINAL = {} :: TERMINAL
|
||||||
local Command = {} :: command_builder
|
local Command = {} :: command_builder
|
||||||
|
|
||||||
local username = TERMINAL.TEXT.GREEN(SHELL.SYSTEM.USERNAME)
|
local OUT_COLOR = TERMINAL.OUT.COLOR.BLUE("hi")
|
||||||
|
|
||||||
|
local username = SHELL.SYSTEM.USERNAME
|
||||||
local hostname = SHELL.SYSTEM.HOSTNAME
|
local hostname = SHELL.SYSTEM.HOSTNAME
|
||||||
|
|
||||||
SHELL.PROMPT = `{username}@{hostname} λ `
|
SHELL.PROMPT = `{username}@{hostname} λ `
|
||||||
|
Reference in New Issue
Block a user