Skip to content

Commit

Permalink
feat: add image fetched from web
Browse files Browse the repository at this point in the history
  • Loading branch information
InioX committed Dec 23, 2023
1 parent 0147e64 commit 7b29a2d
Show file tree
Hide file tree
Showing 7 changed files with 738 additions and 160 deletions.
182 changes: 180 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ prettytable-rs = "0.10.0"
serde_json = "1.0.107"
update-informer = "1.1.0"
upon = "0.8.0"
reqwest = { version = "0.11.23", features = ["blocking"] }
openssl = { version = "0.10", features = ["vendored"] }

[workspace]
members = ["material-color-utilities-rs"]
25 changes: 16 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ use material_color_utilities_rs::{
scheme::{scheme::Scheme, scheme_android::SchemeAndroid},
};



use clap::{Parser, ValueEnum};
use color_eyre::{eyre::Result, Report};
use log::LevelFilter;
Expand Down Expand Up @@ -56,17 +54,17 @@ fn main() -> Result<(), Report> {
} else {
LevelFilter::Warn
};

setup_logging(log_level)?;

check_version();

let source_color = get_source_color(&args.source)?;

let mut palette: CorePalette = generate_palette(&args.palette.unwrap(), source_color)?;

let config: ConfigFile = ConfigFile::read(&args)?;

let default_scheme = args
.mode
.expect("Something went wrong while parsing the mode");
Expand All @@ -89,7 +87,15 @@ fn main() -> Result<(), Report> {
}

if args.dry_run == Some(false) {
Template::generate(&schemes, &config.templates, &args.source, &config.config.prefix, &source_color, &default_scheme, &config.config.custom_keywords)?;
Template::generate(
&schemes,
&config.templates,
&args.source,
&config.config.prefix,
&source_color,
&default_scheme,
&config.config.custom_keywords,
)?;

if config.config.reload_apps == Some(true) {
#[cfg(any(target_os = "linux", target_os = "netbsd"))]
Expand All @@ -100,6 +106,7 @@ fn main() -> Result<(), Report> {
let path = match &args.source {
Source::Image { path } => path,
Source::Color { .. } => return Ok(()),
Source::WebImage { .. } => return Ok(()),
};

#[cfg(any(target_os = "linux", target_os = "netbsd"))]
Expand Down
2 changes: 2 additions & 0 deletions src/util/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub struct Cli {
pub enum Source {
/// The image to use for generating a color scheme
Image { path: String },
/// The image to fetch from web and use for generating a color scheme
WebImage { url: String },
/// The source color to use for generating a color scheme
#[clap(subcommand)]
Color(ColorFormat),
Expand Down
Loading

0 comments on commit 7b29a2d

Please sign in to comment.