Compare commits

6 Commits

Author SHA1 Message Date
47266c6667 remove TERMINAL.OUT.STYLE 2025-01-02 02:29:51 -05:00
7c9b598d5f lambdashell as the version name 2025-01-02 01:54:49 -05:00
3c92a89190 rainbowify include background and foreground 2025-01-02 01:54:29 -05:00
73b46b2a99 opt-level = "z", default config correction, and types 2024-12-31 17:54:43 -05:00
3e0830c082 type checking 2024-12-30 14:32:33 -05:00
3947adc73e examples 2024-12-29 23:07:49 -05:00
5 changed files with 106 additions and 26 deletions

View File

@ -9,6 +9,6 @@ liblambdashell = { path = "../liblambdashell" }
[profile.release] [profile.release]
strip = true strip = true
opt-level = "s" opt-level = "z"
lto = true lto = true
codegen-units = 1 codegen-units = 1

View File

@ -1,6 +1,6 @@
--!strict --!strict
local Username = Shell.system.username local username = SHELL.SYSTEM.USERNAME
local Hostname = Shell.system.hostname local hostname = SHELL.SYSTEM.HOSTNAME
Shell.prompt = `{Username}@{Hostname} λ ` SHELL.PROMPT = `{username}@{hostname} λ `

View File

@ -0,0 +1,39 @@
--!strict
local function rainbowify_foreground(message: string): string
local parsed_terminal_message: {string} = {}
local color_map = {
TERMINAL.OUT.FOREGROUND.RED,
TERMINAL.OUT.FOREGROUND.YELLOW,
TERMINAL.OUT.FOREGROUND.GREEN,
TERMINAL.OUT.FOREGROUND.BLUE,
TERMINAL.OUT.FOREGROUND.MAGENTA,
}
for i, char in message:split('') do
table.insert(parsed_terminal_message, char ~= ' ' and color_map[i%5+1](char) or char)
end
return table.concat(parsed_terminal_message)
end
local function rainbowify_background(message: string): string
local parsed_terminal_message: {string} = {}
local color_map = {
TERMINAL.OUT.BACKGROUND.RED,
TERMINAL.OUT.BACKGROUND.YELLOW,
TERMINAL.OUT.BACKGROUND.GREEN,
TERMINAL.OUT.BACKGROUND.BLUE,
TERMINAL.OUT.BACKGROUND.MAGENTA,
}
for i, char in message:split('') do
table.insert(parsed_terminal_message, char ~= ' ' and color_map[i%5+1](char) or char)
end
return table.concat(parsed_terminal_message)
end
print(rainbowify_foreground("Rainbow foreground"))
print(rainbowify_background("Rainbow background"))
print(
TERMINAL.OUT.BACKGROUND.DARK_GREY(rainbowify_foreground("Rainbow foreground on a dark grey background"))
)

View File

@ -5,18 +5,15 @@ 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 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 +48,65 @@ type SHELL = {
} }
-------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------
type color<T> = (string) -> T type background_styles = {
type colors = { RED: (string) -> string,
RED: color<string>, YELLOW: (string) -> string,
ORANGE: color<string>, GREEN: (string) -> string,
YELLOW: color<string>, BLUE: (string) -> string,
GREEN: color<string>, MAGENTA: (string) -> string,
BLUE: color<string>, GREY: (string) -> string,
PURPLE: color<string> BLACK: (string) -> string,
} CYAN: (string) -> string,
type text_style = { WHITE: (string) -> string,
STYLE: { DARK_GREY: (string) -> string,
BACKGROUND: colors, DARK_RED: (string) -> string,
FOREGROUND: colors DARK_GREEN: (string) -> string,
DARK_CYAN: (string) -> string,
DARK_YELLOW: (string) -> string,
DARK_MAGENTA: (string) -> string,
DARK_BLUE: (string) -> string,
UNDERLINED: (string) -> string,
UNDERLINE_DARK_GREY: (string) -> string,
UNDERLINE_DARK_RED: (string) -> string,
UNDERLINE_DARK_GREEN: (string) -> string,
UNDERLINE_DARK_CYAN: (string) -> string,
UNDERLINE_DARK_YELLOW: (string) -> string,
UNDERLINE_DARK_MAGENTA: (string) -> string,
UNDERLINE_DARK_BLUE: (string) -> string,
UNDERLINE_RED: (string) -> string,
UNDERLINE_GREY: (string) -> string,
UNDERLINE_BLACK: (string) -> string,
UNDERLINE_GREEN: (string) -> string,
UNDERLINE_YELLOW: (string) -> string,
UNDERLINE_BLUE: (string) -> string,
UNDERLINE_MAGENTA: (string) -> string,
UNDERLINE_CYAN: (string) -> string,
UNDERLINE_WHITE: (string) -> string,
BOLD: (string) -> string,
} }
type foreground_styles = {
RED: (string) -> string,
GREY: (string) -> string,
BLACK: (string) -> string,
GREEN: (string) -> string,
YELLOW: (string) -> string,
BLUE: (string) -> string,
MAGENTA: (string) -> string,
CYAN: (string) -> string,
WHITE: (string) -> string,
DARK_GREY: (string) -> string,
DARK_RED: (string) -> string,
DARK_GREEN: (string) -> string,
DARK_CYAN: (string) -> string,
DARK_YELLOW: (string) -> string,
DARK_MAGENTA: (string) -> string,
DARK_BLUE: (string) -> string,
} }
type TERMINAL = { type TERMINAL = {
TEXT: text_style OUT: {
BACKGROUND: background_styles,
FOREGROUND: foreground_styles
}
} }
-------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------
@ -104,7 +143,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} λ `

View File

@ -27,7 +27,7 @@ pub struct Cli {
pub fn parser() -> Option<Cli> { pub fn parser() -> Option<Cli> {
let cli_parser = Cli::parse(); let cli_parser = Cli::parse();
if cli_parser.version { if cli_parser.version {
println!("Lambda Shell, version: {}.", VERSION); println!("lambdashell, version: {}.", VERSION);
println!("liblambdashell, version: {}.", liblambdashell::VERSION); println!("liblambdashell, version: {}.", liblambdashell::VERSION);
return None //stop here return None //stop here
} }