forked from StrafesNET/map-tool
don't replace std Result
This commit is contained in:
parent
1a6202ae66
commit
2a55ef90df
28
src/main.rs
28
src/main.rs
@ -95,7 +95,7 @@ fn get_script_refs(dom:&rbx_dom_weak::WeakDom) -> Vec<rbx_dom_weak::types::Ref>{
|
|||||||
scripts
|
scripts
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_id() -> Result<u32>{
|
fn get_id() -> BoxResult<u32>{
|
||||||
match std::fs::read_to_string("id"){
|
match std::fs::read_to_string("id"){
|
||||||
Ok(id_file)=>Ok(id_file.parse::<u32>()?),
|
Ok(id_file)=>Ok(id_file.parse::<u32>()?),
|
||||||
Err(e) => match e.kind() {
|
Err(e) => match e.kind() {
|
||||||
@ -105,7 +105,7 @@ fn get_id() -> Result<u32>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_set_from_file(file:&str) -> Result<std::collections::HashSet<String>>{
|
fn get_set_from_file(file:&str) -> BoxResult<std::collections::HashSet<String>>{
|
||||||
let mut set=std::collections::HashSet::<String>::new();
|
let mut set=std::collections::HashSet::<String>::new();
|
||||||
for entry in std::fs::read_dir(file)? {
|
for entry in std::fs::read_dir(file)? {
|
||||||
set.insert(std::fs::read_to_string(entry?.path())?);
|
set.insert(std::fs::read_to_string(entry?.path())?);
|
||||||
@ -113,15 +113,15 @@ fn get_set_from_file(file:&str) -> Result<std::collections::HashSet<String>>{
|
|||||||
Ok(set)
|
Ok(set)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_allowed_set() -> Result<std::collections::HashSet<String>>{
|
fn get_allowed_set() -> BoxResult<std::collections::HashSet<String>>{
|
||||||
get_set_from_file("scripts/allowed")
|
get_set_from_file("scripts/allowed")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_blocked() -> Result<std::collections::HashSet<String>>{
|
fn get_blocked() -> BoxResult<std::collections::HashSet<String>>{
|
||||||
get_set_from_file("scripts/blocked")
|
get_set_from_file("scripts/blocked")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_allowed_map() -> Result<std::collections::HashMap::<u32,String>>{
|
fn get_allowed_map() -> BoxResult<std::collections::HashMap::<u32,String>>{
|
||||||
let mut allowed_map = std::collections::HashMap::<u32,String>::new();
|
let mut allowed_map = std::collections::HashMap::<u32,String>::new();
|
||||||
for entry in std::fs::read_dir("scripts/allowed")? {
|
for entry in std::fs::read_dir("scripts/allowed")? {
|
||||||
let entry=entry?;
|
let entry=entry?;
|
||||||
@ -130,7 +130,7 @@ fn get_allowed_map() -> Result<std::collections::HashMap::<u32,String>>{
|
|||||||
Ok(allowed_map)
|
Ok(allowed_map)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_replace_map() -> Result<std::collections::HashMap::<String,u32>>{
|
fn get_replace_map() -> BoxResult<std::collections::HashMap::<String,u32>>{
|
||||||
let mut replace = std::collections::HashMap::<String,u32>::new();
|
let mut replace = std::collections::HashMap::<String,u32>::new();
|
||||||
for entry in std::fs::read_dir("scripts/replace")? {
|
for entry in std::fs::read_dir("scripts/replace")? {
|
||||||
let entry=entry?;
|
let entry=entry?;
|
||||||
@ -143,7 +143,7 @@ fn check_source_illegal_keywords(source:&String)->bool{
|
|||||||
source.find("getfenv").is_some()||source.find("require").is_some()
|
source.find("getfenv").is_some()||source.find("require").is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn download(map_list: Vec<u64>) -> Result<()>{
|
fn download(map_list: Vec<u64>) -> BoxResult<()>{
|
||||||
let header=format!("Cookie: .ROBLOSECURITY={}",std::env::var("RBXCOOKIE")?);
|
let header=format!("Cookie: .ROBLOSECURITY={}",std::env::var("RBXCOOKIE")?);
|
||||||
let shared_args=&[
|
let shared_args=&[
|
||||||
"-q",
|
"-q",
|
||||||
@ -167,7 +167,7 @@ enum Scan{
|
|||||||
Flagged,
|
Flagged,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scan() -> Result<()>{
|
fn scan() -> BoxResult<()>{
|
||||||
let mut id = get_id()?;
|
let mut id = get_id()?;
|
||||||
//Construct allowed scripts
|
//Construct allowed scripts
|
||||||
let allowed_set = get_allowed_set()?;
|
let allowed_set = get_allowed_set()?;
|
||||||
@ -225,7 +225,7 @@ fn scan() -> Result<()>{
|
|||||||
std::fs::write("id",id.to_string())?;
|
std::fs::write("id",id.to_string())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn extract(file_id:u64) -> Result<()>{
|
fn extract(file_id:u64) -> BoxResult<()>{
|
||||||
let mut id = 0;
|
let mut id = 0;
|
||||||
//Construct allowed scripts
|
//Construct allowed scripts
|
||||||
let mut script_set = std::collections::HashSet::<String>::new();
|
let mut script_set = std::collections::HashSet::<String>::new();
|
||||||
@ -265,7 +265,7 @@ fn extract(file_id:u64) -> Result<()>{
|
|||||||
println!("extracted {} {}",id,if id==1 {"script"}else{"scripts"});
|
println!("extracted {} {}",id,if id==1 {"script"}else{"scripts"});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn replace() -> Result<()>{
|
fn replace() -> BoxResult<()>{
|
||||||
let allowed_map=get_allowed_map()?;
|
let allowed_map=get_allowed_map()?;
|
||||||
let replace_map=get_replace_map()?;
|
let replace_map=get_replace_map()?;
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ fn replace() -> Result<()>{
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn upload() -> Result<()>{
|
fn upload() -> BoxResult<()>{
|
||||||
//interactive prompt per upload:
|
//interactive prompt per upload:
|
||||||
//Creator: [auto fill creator]
|
//Creator: [auto fill creator]
|
||||||
//DisplayName: [auto fill DisplayName]
|
//DisplayName: [auto fill DisplayName]
|
||||||
@ -348,7 +348,7 @@ enum ScriptActionParseResult {
|
|||||||
struct ParseScriptActionErr;
|
struct ParseScriptActionErr;
|
||||||
impl std::str::FromStr for ScriptActionParseResult {
|
impl std::str::FromStr for ScriptActionParseResult {
|
||||||
type Err=ParseScriptActionErr;
|
type Err=ParseScriptActionErr;
|
||||||
fn from_str(s: &str) -> StdResult<Self, Self::Err>{
|
fn from_str(s: &str) -> Result<Self, Self::Err>{
|
||||||
if s=="pass\n"||s=="1\n"{
|
if s=="pass\n"||s=="1\n"{
|
||||||
Ok(Self::Pass)
|
Ok(Self::Pass)
|
||||||
}else if s=="block\n"{
|
}else if s=="block\n"{
|
||||||
@ -363,7 +363,7 @@ impl std::str::FromStr for ScriptActionParseResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn interactive() -> Result<()>{
|
fn interactive() -> BoxResult<()>{
|
||||||
let mut id=get_id()?;
|
let mut id=get_id()?;
|
||||||
//Construct allowed scripts
|
//Construct allowed scripts
|
||||||
let mut allowed_set=get_allowed_set()?;
|
let mut allowed_set=get_allowed_set()?;
|
||||||
@ -528,7 +528,7 @@ fn interactive() -> Result<()>{
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> BoxResult<()> {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
match cli.command {
|
match cli.command {
|
||||||
Commands::Download(map_list)=>download(map_list.maps),
|
Commands::Download(map_list)=>download(map_list.maps),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
pub use crate::error::Error;
|
pub use crate::error::Error;
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
pub type BoxResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
||||||
pub type StdResult<T, E> = std::result::Result<T, E>;
|
|
||||||
|
|
||||||
// i just wanted to mess around with macros a bit
|
// i just wanted to mess around with macros a bit
|
||||||
// so heres labelprint as a macro
|
// so heres labelprint as a macro
|
||||||
|
Loading…
Reference in New Issue
Block a user