forked from StrafesNET/map-tool
redo displayname test
This commit is contained in:
parent
e626131d95
commit
5915dd730f
28
src/main.rs
28
src/main.rs
@ -530,6 +530,27 @@ impl std::str::FromStr for ScriptActionParseResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_first_letter_lowercase(s:&str)->bool{
|
||||||
|
s.chars().next().map(char::is_lowercase).unwrap_or(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_title_case(display_name:&str)->bool{
|
||||||
|
display_name.len()!=0
|
||||||
|
&&!is_first_letter_lowercase(display_name)
|
||||||
|
&&{
|
||||||
|
let display_name_pattern=lazy_regex::regex!(r"\b\S+");
|
||||||
|
display_name_pattern.find_iter(display_name)
|
||||||
|
.all(|capture|match capture.as_str(){
|
||||||
|
"a"=>true,
|
||||||
|
"an"=>true,
|
||||||
|
"and"=>true,
|
||||||
|
"the"=>true,
|
||||||
|
"of"=>true,
|
||||||
|
other=>!is_first_letter_lowercase(other),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn interactive() -> AResult<()>{
|
fn interactive() -> AResult<()>{
|
||||||
let mut id=get_id()?;
|
let mut id=get_id()?;
|
||||||
//Construct allowed scripts
|
//Construct allowed scripts
|
||||||
@ -538,7 +559,6 @@ fn interactive() -> AResult<()>{
|
|||||||
let mut replace_map=get_replace_map()?;
|
let mut replace_map=get_replace_map()?;
|
||||||
let mut blocked = get_blocked()?;
|
let mut blocked = get_blocked()?;
|
||||||
let model_name_pattern=lazy_regex::regex!(r"^[a-z0-9_]+$");
|
let model_name_pattern=lazy_regex::regex!(r"^[a-z0-9_]+$");
|
||||||
let display_name_pattern=lazy_regex::regex!(r"\b[a-z]");
|
|
||||||
|
|
||||||
'map_loop: for entry in std::fs::read_dir("maps/unprocessed")? {
|
'map_loop: for entry in std::fs::read_dir("maps/unprocessed")? {
|
||||||
let file_thing=entry?;
|
let file_thing=entry?;
|
||||||
@ -571,7 +591,7 @@ fn interactive() -> AResult<()>{
|
|||||||
//mark file as edited so a new file is generated
|
//mark file as edited so a new file is generated
|
||||||
replace_count+=1;
|
replace_count+=1;
|
||||||
}
|
}
|
||||||
if displayname.len()==0||display_name_pattern.is_match(displayname.as_str()){
|
if !is_title_case(displayname.as_str()){
|
||||||
//illegal
|
//illegal
|
||||||
let new_display_name;
|
let new_display_name;
|
||||||
loop{
|
loop{
|
||||||
@ -579,7 +599,7 @@ fn interactive() -> AResult<()>{
|
|||||||
std::io::Write::flush(&mut std::io::stdout())?;
|
std::io::Write::flush(&mut std::io::stdout())?;
|
||||||
let mut input_string=String::new();
|
let mut input_string=String::new();
|
||||||
std::io::stdin().read_line(&mut input_string)?;
|
std::io::stdin().read_line(&mut input_string)?;
|
||||||
if displayname.len()!=0||!display_name_pattern.is_match(input_string.trim()){
|
if is_title_case(input_string.trim()){
|
||||||
new_display_name=input_string.trim().to_owned();
|
new_display_name=input_string.trim().to_owned();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -665,7 +685,7 @@ fn interactive() -> AResult<()>{
|
|||||||
ScriptActionParseResult::Delete => ScriptAction::Delete,
|
ScriptActionParseResult::Delete => ScriptAction::Delete,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let location=get_full_name(&dom, script);
|
let location=get_full_name(&dom, script);
|
||||||
match source_action{
|
match source_action{
|
||||||
ScriptAction::Pass => println!("passed source location={}",location),
|
ScriptAction::Pass => println!("passed source location={}",location),
|
||||||
|
Loading…
Reference in New Issue
Block a user