-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
exec .zenshell files + shell extensions
Co-authored-by: Tristan Poland (Trident_For_U) <[email protected]>
- Loading branch information
1 parent
b289e3d
commit 48bdd14
Showing
16 changed files
with
494 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,66 @@ | ||
use std::process::Command; | ||
use std::{ffi::OsStr, process::Command}; | ||
|
||
|
||
|
||
|
||
|
||
use crate::core::repl::repl::evaluate_command; | ||
|
||
use super::COMMAND_LIST; | ||
|
||
pub(crate) fn say_hello() { | ||
pub(crate) fn say_hello() -> anyhow::Result<()> { | ||
println!("Hello, World!"); | ||
Ok(()) | ||
} | ||
|
||
pub(crate) fn echo(args: Vec<String>) { | ||
println!("{}", args.join(" ")) | ||
pub(crate) fn echo(args: Vec<String>) -> anyhow::Result<()> { | ||
println!("{}", args.join(" ")); | ||
Ok(()) | ||
} | ||
|
||
pub(crate) fn exit() { | ||
pub(crate) fn exit() -> anyhow::Result<()> { | ||
println!("Exiting..."); | ||
std::process::exit(0) | ||
} | ||
|
||
pub(crate) fn clear() { | ||
pub(crate) fn clear() -> anyhow::Result<()> { | ||
println!("Clearing screen..., running command"); | ||
let _result = if cfg!(target_os = "windows") { | ||
Command::new("cmd").args(["/c", "cls"]).spawn() | ||
} else { | ||
Command::new("clear").spawn() | ||
}; | ||
Ok(()) | ||
} | ||
|
||
pub(crate) fn help() { | ||
pub(crate) fn help() -> anyhow::Result<()> { | ||
println!("Commands:"); | ||
for cmd in COMMAND_LIST.commands.read().iter() { | ||
println!("{:#}", cmd); | ||
} | ||
Ok(()) | ||
} | ||
pub(crate) fn exec(args: Vec<String>) -> anyhow::Result<()> { | ||
let file_path_str = &args[0]; | ||
let file_path = std::path::Path::new(file_path_str); | ||
println!("File path: {:#?}", file_path); | ||
|
||
if !file_path.is_file() { | ||
eprintln!("Error: File does not exist or is not a valid file: {}", file_path.display()); | ||
return Ok(()); | ||
} | ||
if file_path.extension() != Some(OsStr::new("zensh")) { | ||
eprintln!("Error: File is not a zenshell script: {:#?}", file_path.extension()); | ||
//TODO: dont panic on this error | ||
return Ok(()); | ||
} | ||
println!("Executing file: {:#?}", file_path); | ||
let file_content = std::fs::read_to_string(file_path)?; | ||
if file_content.is_empty() { | ||
eprintln!("Error: file has no content. Is this a valid zenshell script?"); | ||
return Ok(()); | ||
} | ||
println!("File contents:\n{file_content}"); | ||
evaluate_command(file_content.trim())?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod logger; | ||
pub mod mathi; | ||
pub mod splash; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
use colored::Colorize; | ||
use log::info; | ||
|
||
pub fn print_splash() { | ||
info!( | ||
println!( | ||
"{}", | ||
format!( | ||
r#" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "plugin_api" | ||
version = "0.3.0" | ||
authors = ["Tristan Poland <[email protected]>"] | ||
description = "Horizon Plugins API" | ||
license = "MIT" | ||
edition = "2021" | ||
|
||
[build-dependencies] | ||
toml_edit = "0.22.22" | ||
pathdiff = "0.2.3" | ||
|
||
[dependencies] | ||
async-trait = "0.1.83" | ||
tokio = { version = "1.42.0", features = ["rt", "net", "rt-multi-thread"] } | ||
uuid = "1.11.0" | ||
socketioxide = "0.15.0" | ||
horizon-plugin-api = "0.1.11" | ||
# | ||
# | ||
# | ||
# | ||
###### BEGIN AUTO-GENERATED PLUGIN DEPENDENCIES - DO NOT EDIT THIS SECTION ###### | ||
player_lib = { path = "../plugins/player_lib", version = "0.1.0" } | ||
###### END AUTO-GENERATED PLUGIN DEPENDENCIES ###### |
Oops, something went wrong.