convert indentation to tabs
This commit is contained in:
parent
c4559b8aa1
commit
c08d0a20e2
@ -71,9 +71,9 @@ impl Vm {
|
||||
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.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 thiserror::Error;
|
||||
|
||||
const DEFAULT_CONFIG_CONTENT: &str = r#"--!strict
|
||||
pub const DEFAULT_CONFIG_CONTENT: &str = r#"--!strict
|
||||
|
||||
local username = SHELL.SYSTEM.USERNAME
|
||||
local hostname = SHELL.SYSTEM.HOSTNAME
|
||||
@ -115,7 +115,3 @@ pub fn history_file() -> Option<PathBuf> {
|
||||
config_file.push(".history");
|
||||
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 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 norc: bool
|
||||
@ -20,11 +11,11 @@ struct Storage {
|
||||
}
|
||||
|
||||
trait ShellLuauVm {
|
||||
fn shell_vm_exec(&self, source: String) -> Option<()>;
|
||||
fn shell_vm_exec(&self, source: String);
|
||||
}
|
||||
impl ShellLuauVm for LambdaShell {
|
||||
fn shell_vm_exec(&self, source: String) -> Option<()> {
|
||||
vm::Vm::new().map_or(None, |vm| vm.exec(source))
|
||||
fn shell_vm_exec(&self, source: String) {
|
||||
vm::Vm::new().map(|vm| vm.exec(source));
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,13 +56,12 @@ impl LambdaShell {
|
||||
}
|
||||
|
||||
fn rc_parse(&self) {
|
||||
let rc_file = match self.config.norc {
|
||||
true => rc::none(),
|
||||
false => rc::config_file(),
|
||||
};
|
||||
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))
|
||||
);
|
||||
if !self.config.norc {
|
||||
rc::config_file().map(|conf_file| fs::read_to_string(conf_file).map_or_else(
|
||||
|read_err| println!("{read_err}"),
|
||||
|luau_conf| self.shell_vm_exec(luau_conf)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn start(&mut self) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user