Adds threading max count and better naming
This commit is contained in:
parent
c632641b39
commit
d0f14855fd
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Palette: Palettes</title> <style> body{background-color: #332f35;
|
||||
margin: 0;
|
||||
font-family: "Open Sans","Segoe UI",Tahoma,sans-serif;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
}
|
||||
.custom-div { display: flex;
|
||||
flex-wrap: wrap;
|
||||
flex-grow: 0;
|
||||
padding: 5px;
|
||||
background: #27232a;
|
||||
text-align: center;
|
||||
margin: 10px 0 20px;
|
||||
}
|
||||
h1 {
|
||||
text-transform: uppercase;
|
||||
color: #eaeaea;
|
||||
}
|
||||
</style></head><body>
|
||||
<h1>Beach</h1><div class='custom-div'> <div class='color' style='background:#787A7C; color: #FFFFFF; min-width: 25%; height: 75px; line-height: 75px; font-size: 14px'>
|
||||
#787A7C
|
||||
</div> <div class='color' style='background:#798086; color: #FFFFFF; min-width: 25%; height: 75px; line-height: 75px; font-size: 14px'>
|
||||
#798086
|
||||
</div> <div class='color' style='background:#838484; color: #FFFFFF; min-width: 25%; height: 75px; line-height: 75px; font-size: 14px'>
|
||||
#838484
|
||||
</div> <div class='color' style='background:#9D9C9E; color: #000000; min-width: 25%; height: 75px; line-height: 75px; font-size: 14px'>
|
||||
#9D9C9E
|
||||
</div> <div class='color' style='background:#71808E; color: #FFFFFF; min-width: 25%; height: 75px; line-height: 75px; font-size: 14px'>
|
||||
#71808E
|
||||
</div> <div class='color' style='background:#A2A09F; color: #000000; min-width: 25%; height: 75px; line-height: 75px; font-size: 14px'>
|
||||
#A2A09F
|
||||
</div></div></body></html>
|
||||
12
src/main.rs
12
src/main.rs
|
|
@ -40,6 +40,10 @@ struct Cli {
|
|||
/// Extra Verbosity
|
||||
#[arg(short, default_value_t = false)]
|
||||
verbosity: bool,
|
||||
|
||||
/// Number of threads (Defaults to the max number of threads)
|
||||
#[arg(long)]
|
||||
threads: Option<usize>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
@ -51,6 +55,12 @@ fn main() {
|
|||
.tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ ");
|
||||
|
||||
let cli = Cli::parse();
|
||||
if let Some(t) = cli.threads {
|
||||
rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(t)
|
||||
.build_global()
|
||||
.unwrap();
|
||||
}
|
||||
let export_path = match cli.export.clone() {
|
||||
Some(e) => e,
|
||||
None => cli.image[0]
|
||||
|
|
@ -91,7 +101,7 @@ fn main() {
|
|||
let pb = m.add(ProgressBar::new(cli.runs.unwrap_or(8)));
|
||||
pb.enable_steady_tick(Duration::from_millis(100));
|
||||
pb.set_style(spinner_style.clone());
|
||||
pb.set_prefix(format!("[{:?}]", small_name(image)));
|
||||
pb.set_prefix(small_name(image));
|
||||
let r = function(image, &cli, &pb);
|
||||
pb_general.inc(1);
|
||||
r
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use std::{
|
||||
borrow::Cow,
|
||||
fs::File,
|
||||
io::{BufWriter, Write},
|
||||
path::{Path, PathBuf},
|
||||
|
|
@ -8,8 +9,29 @@ use crate::structs::ColorIndex;
|
|||
|
||||
/// Make a smaller name
|
||||
pub(crate) fn small_name(name: &Path) -> String {
|
||||
let os = format!("{:?}", name.to_string_lossy());
|
||||
os
|
||||
let ancs = name.ancestors().collect::<Vec<&Path>>();
|
||||
let l = ancs.len();
|
||||
let (beg, end, file_name) = if l > 2 {
|
||||
(
|
||||
ancs[l - 2].to_string_lossy(),
|
||||
ancs[1].file_name().unwrap().to_string_lossy(),
|
||||
ancs[0].file_name().unwrap().to_string_lossy(),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
Cow::Borrowed(""),
|
||||
Cow::Borrowed(""),
|
||||
ancs[0].file_name().unwrap().to_string_lossy(),
|
||||
)
|
||||
};
|
||||
|
||||
if l > 3 {
|
||||
format!("{}/../{}/{}", beg, end, file_name)
|
||||
} else if l > 2 {
|
||||
format!("{}/{}", beg, file_name)
|
||||
} else {
|
||||
format!("{}", file_name)
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract the image name
|
||||
|
|
@ -17,8 +39,7 @@ pub(crate) fn extract_name(image: &Path) -> String {
|
|||
image
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.split(".")
|
||||
.next()
|
||||
.unwrap()
|
||||
|
|
|
|||
Reference in New Issue