-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #11
- Loading branch information
Showing
11 changed files
with
144 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "autorun" | ||
version = "0.4.0" | ||
version = "0.4.1" | ||
authors = ["Vurv78 <[email protected]>"] | ||
edition = "2018" | ||
|
||
|
@@ -23,4 +23,9 @@ atomic = "0.5.0" | |
|
||
# Misc | ||
dirs = "3.0.2" # To get your home directory. | ||
anyhow = "1.0.42" | ||
anyhow = "1.0.42" | ||
|
||
# Logging | ||
chrono = "0.4.19" | ||
log = "0.4.14" | ||
simplelog = "0.10.0" |
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,5 +1,5 @@ | ||
@echo off | ||
rustup target add i686-pc-windows-msvc | ||
cargo build --release --target=i686-pc-windows-msvc | ||
move %cd%\target\i686-pc-windows-msvc\release\Autorun.dll %cd%\Autorun_Win_32.dll | ||
move %cd%\target\i686-pc-windows-msvc\release\Autorun.dll %cd%\gmsv_autorun_win32.dll | ||
pause |
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,4 +1,4 @@ | ||
@echo off | ||
cargo build --release | ||
move %cd%\target\release\Autorun.dll %cd%\Autorun_Win_64.dll | ||
move %cd%\target\release\Autorun.dll %cd%\gmsv_autorun_win64.dll | ||
pause |
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,42 @@ | ||
use std::path::Path; | ||
use crate::sys::runLua; | ||
|
||
pub(crate) fn try_process_input() -> anyhow::Result<()> { | ||
// Loop forever in this thread, since it is separate from Gmod, and take in user input. | ||
let mut buffer = String::new(); | ||
|
||
std::io::stdin().read_line(&mut buffer)?; | ||
let (word, rest) = buffer.split_once(' ').unwrap_or( (&buffer.trim_end(), "") ); | ||
|
||
debug!("Command used: [{}], rest [{}]", word, rest); | ||
|
||
match word { | ||
"lua_run" => { | ||
match runLua(rest) { | ||
Ok(_) => println!("Ran successfully!"), | ||
Err(why) => error!("{}", why) | ||
} | ||
}, | ||
"lua_openscript" => { | ||
let path = rest.trim_end(); | ||
match std::fs::read_to_string( Path::new(path) ) { | ||
Err(why) => error!("Errored on lua_openscript. [{}]", why), | ||
Ok(contents) => { | ||
match runLua( &contents ) { | ||
Ok(_) => info!("Ran file {} successfully!", path), | ||
Err(why) => error!("Errored when running file at path '{}'. [{}]", path, why) | ||
} | ||
} | ||
} | ||
}, | ||
"help" => { | ||
println!("Commands list:"); | ||
println!("lua_run <code> | Runs lua code on the currently loaded lua state. Will print if any errors occur."); | ||
println!("lua_openscript <file_dir> | Runs a lua script located at file_dir, this dir being a full directory, not relative or anything."); | ||
println!("help | Prints this out."); | ||
} | ||
_ => () | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use simplelog::*; | ||
|
||
use chrono::prelude::*; | ||
use std::fs::File; | ||
use crate::sys::statics::SAUTORUN_LOG_DIR; | ||
|
||
pub fn init() -> anyhow::Result<()> { | ||
if !SAUTORUN_LOG_DIR.exists() { | ||
std::fs::create_dir_all(&*SAUTORUN_LOG_DIR)?; | ||
} | ||
|
||
let log_file_handle = File::create( SAUTORUN_LOG_DIR.join( format!("{}.log", Local::now().format("%B %d, %Y %I-%M %P") ) ) )?; | ||
|
||
let configs = ConfigBuilder::new() | ||
.set_level_color( Level::Info, Some( Color::Cyan) ) | ||
.set_level_color( Level::Error, Some( Color::Red) ) | ||
.set_level_color( Level::Warn, Some( Color::Yellow) ) | ||
.build(); | ||
|
||
CombinedLogger::init( | ||
vec![ | ||
TermLogger::new( | ||
// Logs that are level 'info' or above will be sent to the console. | ||
LevelFilter::Info, | ||
configs, | ||
TerminalMode::Mixed, | ||
ColorChoice::Auto | ||
), | ||
WriteLogger::new( | ||
// Logs that are level 'info' or above will be written to the log. | ||
LevelFilter::Info, | ||
Config::default(), | ||
log_file_handle | ||
) | ||
] | ||
)?; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
pub mod statics; // Global variables. | ||
pub mod funcs; | ||
pub mod runlua; | ||
pub mod runlua; | ||
|
||
pub use runlua::*; |
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