forked from StrafesNET/asset-tool
import PathBuf
This commit is contained in:
parent
8f2115ebf2
commit
b64da4511c
48
src/main.rs
48
src/main.rs
@ -1,4 +1,4 @@
|
||||
use std::io::Read;
|
||||
use std::{io::Read,path::PathBuf};
|
||||
use clap::{Args,Parser,Subcommand};
|
||||
use anyhow::Result as AResult;
|
||||
use futures::StreamExt;
|
||||
@ -6,7 +6,7 @@ use rbx_dom_weak::types::Ref;
|
||||
use tokio::io::AsyncReadExt;
|
||||
|
||||
type AssetID=u64;
|
||||
type AssetIDFileMap=Vec<(AssetID,std::path::PathBuf)>;
|
||||
type AssetIDFileMap=Vec<(AssetID,PathBuf)>;
|
||||
const CONCURRENT_DECODE:usize=8;
|
||||
const CONCURRENT_REQUESTS:usize=32;
|
||||
|
||||
@ -25,7 +25,7 @@ struct Cli{
|
||||
#[arg(long)]
|
||||
cookie_env:Option<String>,
|
||||
#[arg(long)]
|
||||
cookie_file:Option<std::path::PathBuf>,
|
||||
cookie_file:Option<PathBuf>,
|
||||
//TODO: read the versions.json file instead of doing this
|
||||
//TODO: write file dates instead of versions.json
|
||||
#[arg(long)]
|
||||
@ -52,10 +52,10 @@ struct Cli{
|
||||
git_committer_email:Option<String>,
|
||||
|
||||
#[arg(short,long)]
|
||||
input:Option<std::path::PathBuf>,
|
||||
input:Option<PathBuf>,
|
||||
|
||||
#[arg(short,long)]
|
||||
output:Option<std::path::PathBuf>,
|
||||
output:Option<PathBuf>,
|
||||
|
||||
#[command(subcommand)]
|
||||
command:Commands,
|
||||
@ -86,7 +86,7 @@ struct AssetIDList{
|
||||
|
||||
#[derive(Args)]
|
||||
struct PathBufList{
|
||||
paths:Vec<std::path::PathBuf>
|
||||
paths:Vec<PathBuf>
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
@ -205,7 +205,7 @@ async fn main()->AResult<()>{
|
||||
enum Cookie{
|
||||
Literal(String),
|
||||
Environment(String),
|
||||
File(std::path::PathBuf),
|
||||
File(PathBuf),
|
||||
}
|
||||
|
||||
enum ReaderType<R:Read>{
|
||||
@ -380,7 +380,7 @@ struct DownloadHistoryConfig{
|
||||
continue_from_versions:bool,
|
||||
end_version:Option<u64>,
|
||||
start_version:u64,
|
||||
output_folder:std::path::PathBuf,
|
||||
output_folder:PathBuf,
|
||||
cookie:String,
|
||||
asset_id:AssetID,
|
||||
}
|
||||
@ -598,7 +598,7 @@ fn sanitize<'a>(s:&'a str)->std::borrow::Cow<'a,str>{
|
||||
lazy_regex::regex!(r"[^A-z0-9.-]").replace_all(s,"_")
|
||||
}
|
||||
|
||||
fn write_item(dom:&rbx_dom_weak::WeakDom,mut file:std::path::PathBuf,node:&TreeNode,node_name_override:String,mut properties:PropertiesOverride,style:DecompileStyle,write_models:bool,write_scripts:bool)->AResult<()>{
|
||||
fn write_item(dom:&rbx_dom_weak::WeakDom,mut file:PathBuf,node:&TreeNode,node_name_override:String,mut properties:PropertiesOverride,style:DecompileStyle,write_models:bool,write_scripts:bool)->AResult<()>{
|
||||
file.push(sanitize(node_name_override.as_str()).as_ref());
|
||||
match node.class{
|
||||
Class::Folder=>(),
|
||||
@ -759,7 +759,7 @@ fn generate_decompiled_context<R:Read>(input:R)->AResult<DecompiledContext>{
|
||||
|
||||
struct WriteConfig{
|
||||
style:DecompileStyle,
|
||||
output_folder:std::path::PathBuf,
|
||||
output_folder:PathBuf,
|
||||
write_template:bool,
|
||||
write_models:bool,
|
||||
write_scripts:bool,
|
||||
@ -866,8 +866,8 @@ async fn write_files(config:WriteConfig,mut context:DecompiledContext)->AResult<
|
||||
|
||||
struct DecompileConfig{
|
||||
style:DecompileStyle,
|
||||
input_file:std::path::PathBuf,
|
||||
output_folder:std::path::PathBuf,
|
||||
input_file:PathBuf,
|
||||
output_folder:PathBuf,
|
||||
write_template:bool,
|
||||
write_models:bool,
|
||||
write_scripts:bool,
|
||||
@ -899,7 +899,7 @@ async fn decompile(config:DecompileConfig)->AResult<()>{
|
||||
struct WriteCommitConfig{
|
||||
git_committer_name:String,
|
||||
git_committer_email:String,
|
||||
output_folder:std::path::PathBuf,
|
||||
output_folder:PathBuf,
|
||||
style:DecompileStyle,
|
||||
write_template:bool,
|
||||
write_models:bool,
|
||||
@ -990,9 +990,9 @@ async fn write_commit(config:WriteCommitConfig,b:Result<AResult<(AssetVersion,De
|
||||
struct DecompileHistoryConfig{
|
||||
git_committer_name:String,
|
||||
git_committer_email:String,
|
||||
input_folder:std::path::PathBuf,
|
||||
input_folder:PathBuf,
|
||||
style:DecompileStyle,
|
||||
output_folder:std::path::PathBuf,
|
||||
output_folder:PathBuf,
|
||||
write_template:bool,
|
||||
write_models:bool,
|
||||
write_scripts:bool,
|
||||
@ -1041,7 +1041,7 @@ struct DownloadAndDecompileHistoryConfig{
|
||||
git_committer_name:String,
|
||||
git_committer_email:String,
|
||||
style:DecompileStyle,
|
||||
output_folder:std::path::PathBuf,
|
||||
output_folder:PathBuf,
|
||||
write_template:bool,
|
||||
write_models:bool,
|
||||
write_scripts:bool,
|
||||
@ -1119,7 +1119,7 @@ struct FileWithName{
|
||||
name:String,
|
||||
}
|
||||
|
||||
async fn get_file_async(mut path:std::path::PathBuf,file_name:impl AsRef<std::path::Path>)->Result<FileWithName,QueryResolveError>{
|
||||
async fn get_file_async(mut path:PathBuf,file_name:impl AsRef<std::path::Path>)->Result<FileWithName,QueryResolveError>{
|
||||
let name=file_name.as_ref().to_str().unwrap().to_owned();
|
||||
path.push(file_name);
|
||||
match tokio::fs::File::open(path).await{
|
||||
@ -1139,7 +1139,7 @@ struct QuerySingle{
|
||||
script:QueryHandle,
|
||||
}
|
||||
impl QuerySingle{
|
||||
fn rox(search_path:&std::path::PathBuf,search_name:&str)->Self{
|
||||
fn rox(search_path:&PathBuf,search_name:&str)->Self{
|
||||
Self{
|
||||
script:tokio::spawn(get_file_async(search_path.clone(),format!("{}.lua",search_name)))
|
||||
}
|
||||
@ -1160,7 +1160,7 @@ struct QueryTriple{
|
||||
client:QueryHandle,
|
||||
}
|
||||
impl QueryTriple{
|
||||
fn rox_rojo(search_path:&std::path::PathBuf,search_name:&str,search_module:bool)->Self{
|
||||
fn rox_rojo(search_path:&PathBuf,search_name:&str,search_module:bool)->Self{
|
||||
//this should be implemented as constructors of Triplet and Quadruplet to fully support Trey's suggestion
|
||||
let module_name=if search_module{
|
||||
format!("{}.module.lua",search_name)
|
||||
@ -1173,7 +1173,7 @@ impl QueryTriple{
|
||||
client:tokio::spawn(get_file_async(search_path.clone(),format!("{}.client.lua",search_name))),
|
||||
}
|
||||
}
|
||||
fn rojo(search_path:&std::path::PathBuf)->Self{
|
||||
fn rojo(search_path:&PathBuf)->Self{
|
||||
QueryTriple::rox_rojo(search_path,"init",false)
|
||||
}
|
||||
}
|
||||
@ -1243,7 +1243,7 @@ struct QueryQuad{
|
||||
client:QueryHandle,
|
||||
}
|
||||
impl QueryQuad{
|
||||
fn rox_rojo(search_path:&std::path::PathBuf,search_name:&str)->Self{
|
||||
fn rox_rojo(search_path:&PathBuf,search_name:&str)->Self{
|
||||
let fill=QueryTriple::rox_rojo(search_path,search_name,true);
|
||||
Self{
|
||||
module_implicit:QuerySingle::rox(search_path,search_name).script,//Script.lua
|
||||
@ -1452,9 +1452,9 @@ enum CompileStackInstruction{
|
||||
}
|
||||
|
||||
struct CompileConfig{
|
||||
input_folder:std::path::PathBuf,
|
||||
output_file:std::path::PathBuf,
|
||||
template:Option<std::path::PathBuf>,
|
||||
input_folder:PathBuf,
|
||||
output_file:PathBuf,
|
||||
template:Option<PathBuf>,
|
||||
style:Option<DecompileStyle>,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user