convert indentation to tabs
This commit is contained in:
parent
c4559b8aa1
commit
c08d0a20e2
@ -71,9 +71,9 @@ impl Vm {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(&self, source: String) -> Option<()> {
|
pub fn exec(&self, source: String) {
|
||||||
self.set_shell_globals().map_or_else(|e| display_none(e), |()| {
|
self.set_shell_globals().map_or_else(|e| display_none(e), |()| {
|
||||||
self.0.load(source).exec().map_or_else(|e| luau_error(e), |()| Some(()))
|
self.0.load(source).exec().map_or_else(|e| luau_error(e), |()| Some(()))
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
use std::{fs::{self, File}, io::{self, Write}, path::PathBuf};
|
use std::{fs::{self, File}, io::{self, Write}, path::PathBuf};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
const DEFAULT_CONFIG_CONTENT: &str = r#"--!strict
|
pub const DEFAULT_CONFIG_CONTENT: &str = r#"--!strict
|
||||||
|
|
||||||
local username = SHELL.SYSTEM.USERNAME
|
local username = SHELL.SYSTEM.USERNAME
|
||||||
local hostname = SHELL.SYSTEM.HOSTNAME
|
local hostname = SHELL.SYSTEM.HOSTNAME
|
||||||
@ -115,7 +115,3 @@ pub fn history_file() -> Option<PathBuf> {
|
|||||||
config_file.push(".history");
|
config_file.push(".history");
|
||||||
config_file.is_valid_file_or_create("".as_bytes())
|
config_file.is_valid_file_or_create("".as_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn none() -> Option<PathBuf> {
|
|
||||||
None
|
|
||||||
}
|
|
28
src/shell.rs
28
src/shell.rs
@ -1,14 +1,5 @@
|
|||||||
use crate::{ps, commands, rc, vm};
|
use crate::{ps, commands, rc, vm};
|
||||||
use std::{fs, io::{self}};
|
use std::{fs, io::{self}};
|
||||||
use core::fmt;
|
|
||||||
|
|
||||||
fn display_none<T, E>(err: E) -> Option<T>
|
|
||||||
where
|
|
||||||
E: fmt::Display
|
|
||||||
{
|
|
||||||
println!("{err}");
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub norc: bool
|
pub norc: bool
|
||||||
@ -20,11 +11,11 @@ struct Storage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trait ShellLuauVm {
|
trait ShellLuauVm {
|
||||||
fn shell_vm_exec(&self, source: String) -> Option<()>;
|
fn shell_vm_exec(&self, source: String);
|
||||||
}
|
}
|
||||||
impl ShellLuauVm for LambdaShell {
|
impl ShellLuauVm for LambdaShell {
|
||||||
fn shell_vm_exec(&self, source: String) -> Option<()> {
|
fn shell_vm_exec(&self, source: String) {
|
||||||
vm::Vm::new().map_or(None, |vm| vm.exec(source))
|
vm::Vm::new().map(|vm| vm.exec(source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,13 +56,12 @@ impl LambdaShell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn rc_parse(&self) {
|
fn rc_parse(&self) {
|
||||||
let rc_file = match self.config.norc {
|
if !self.config.norc {
|
||||||
true => rc::none(),
|
rc::config_file().map(|conf_file| fs::read_to_string(conf_file).map_or_else(
|
||||||
false => rc::config_file(),
|
|read_err| println!("{read_err}"),
|
||||||
};
|
|luau_conf| self.shell_vm_exec(luau_conf)
|
||||||
rc_file.map(|conf_file| fs::read_to_string(conf_file)
|
));
|
||||||
.map_or_else(|read_err| display_none(read_err), |conf| self.shell_vm_exec(conf))
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(&mut self) {
|
pub fn start(&mut self) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user