From 8a28fd4f2b7dab6124926d4b6979729d40f2c256 Mon Sep 17 00:00:00 2001 From: #84837 Date: Sun, 3 Mar 2024 01:08:17 +0100 Subject: [PATCH 1/7] update deps --- Cargo.lock | 343 +++++++++++++++++++++++++++++++++++++++++++++++++---- Cargo.toml | 12 +- 2 files changed, 329 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index abdf667..9a8f1db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,60 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" + [[package]] name = "atty" version = "0.2.14" @@ -36,9 +90,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" [[package]] name = "byteorder" @@ -61,18 +115,76 @@ dependencies = [ "ansi_term", "atty", "bitflags", - "strsim", + "strsim 0.8.0", "textwrap", "unicode-width", "vec_map", ] +[[package]] +name = "clap" +version = "4.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim 0.11.0", +] + +[[package]] +name = "clap_derive" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + [[package]] name = "color_quant" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + [[package]] name = "heck" version = "0.3.3" @@ -82,6 +194,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -105,6 +223,16 @@ dependencies = [ "num-traits", ] +[[package]] +name = "indexmap" +version = "2.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -113,25 +241,30 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "memchr" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" dependencies = [ "autocfg", "num-integer", @@ -151,9 +284,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -167,7 +300,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -184,9 +317,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -203,26 +336,61 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] +[[package]] +name = "serde" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + [[package]] name = "strsim" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + [[package]] name = "structopt" version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ - "clap", + "clap 2.34.0", "lazy_static", "structopt-derive", ] @@ -233,11 +401,11 @@ version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ - "heck", + "heck 0.3.3", "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -251,6 +419,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -260,6 +439,40 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "toml" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "unicode-ident" version = "1.0.12" @@ -268,9 +481,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" @@ -278,6 +491,12 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "vec_map" version = "0.8.2" @@ -292,10 +511,13 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wifi-qrcode-rs" -version = "0.0.1" +version = "0.0.3" dependencies = [ + "anyhow", + "clap 4.5.1", "qrcode", "structopt", + "toml", ] [[package]] @@ -319,3 +541,78 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" + +[[package]] +name = "winnow" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +dependencies = [ + "memchr", +] diff --git a/Cargo.toml b/Cargo.toml index 9664ccd..5a6a5f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,17 @@ [package] name = "wifi-qrcode-rs" -version = "0.0.2" +version = "0.0.3" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -qrcode = "0.12.0" +anyhow = "1.0" +clap = { version = "4.5.1", features = ["derive"] } +qrcode = "0.12" structopt = "0.3" - +toml = "0.8" +# tempfile = "3.8" +# resvg = "0.36" +# usvg = "0.36" +# tiny-skia = "0.11" From 49b5d952a813700dd0eb25ceccb77b7fba3c1b4c Mon Sep 17 00:00:00 2001 From: #84837 Date: Sun, 3 Mar 2024 01:08:54 +0100 Subject: [PATCH 2/7] implement toml configuration --- src/main.rs | 154 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 114 insertions(+), 40 deletions(-) diff --git a/src/main.rs b/src/main.rs index c08fd36..8254fd5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,54 +1,128 @@ -use qrcode::{render::svg::Color, types::QrError, EcLevel, QrCode}; -use std::fs::File; -use std::io::Write; -use structopt::StructOpt; - -#[derive(StructOpt)] -struct Options { - #[structopt(short, long)] - ssid: String, +use anyhow::{anyhow, Context, Result}; +use clap::Parser; +use qrcode::{render::svg, EcLevel, QrCode}; +use std::{ + fs::File, + io::{BufReader, BufWriter, Read, Write}, + path::PathBuf, +}; +use toml::Value; - #[structopt(short, long)] - password: String, +#[derive(Parser)] +struct Args { + #[arg(short, long, help = "the wifi network's ssid (aka its name)")] + ssid: String, - #[structopt(short, long)] + #[arg( + short, + long, + default_value = "WPA", + help = "the encryption of the wifi network. it can be 'WPA' or 'WEP'." + )] encryption: String, + + #[arg(short, long, help = "the toml configuration file.")] + config: PathBuf, + + #[arg(short, long, default_value = "qrcode.svg")] + output: PathBuf, } -fn generate_qr_code(wifi_info: &str) -> Result { - QrCode::with_error_correction_level(wifi_info.as_bytes(), EcLevel::H).map_err(|e| QrError::from(e)) +struct Consts; + +impl Consts { + const FORMAT: &'static str = "svg"; + const BACKGROUND: &'static str = "#000000"; + const FOREGROUND: &'static str = "#ffffff"; + const SIZE: u32 = 512; } -fn main() { - let options = Options::from_args(); +fn main() -> Result<()> { + let arguments = Args::parse(); + + let f = File::open(&arguments.config)?; + let mut reader = BufReader::new(f); + let mut config_str = String::new(); + reader.read_to_string(&mut config_str)?; + + let toml_config: Value = toml::from_str(&config_str)?; + + let export_format = toml_config["qrcode"]["export"].as_str().unwrap_or_else(|| { + eprintln!("Found invalid or missing value for output format. Falling back to {:?}...", Consts::FORMAT); + Consts::FORMAT + }); + + let size = toml_config["qrcode"]["size"] + .as_str() + .unwrap_or_else(|| { + eprintln!("Failed to get size: falling back to {0}x{0}...", Consts::SIZE); + "512" + }) + .parse::()?; + + let foreground = toml_config["colors"]["foreground"] + .as_str() + .unwrap_or_else(|| { + eprintln!( + "Failed to get foreground color: falling back to {:?}...", + Consts::FOREGROUND + ); + Consts::FOREGROUND + }); - let wifi_info = format!( - "WIFI:T:{};S:{};P:{};;", - options.encryption, - options.ssid, - options.password + let background = toml_config["colors"]["background"] + .as_str() + .unwrap_or_else(|| { + eprintln!( + "Failed to get background color: falling back to {:?}...", + Consts::BACKGROUND + ); + Consts::BACKGROUND + }); + + let password = toml_config["qrcode"]["password"] + .as_str() + .with_context(|| format!("failed to get password from '{:?}'", &arguments.config))?; + + if &arguments.encryption.to_lowercase() != "wpa" + && &arguments.encryption.to_lowercase() != "wep" + { + return Err(anyhow!( + "Invalid encryption '{}'. Choose WEP or WPA.", + &arguments.encryption + )); + } + + let contents_to_encode = format!( + "WIFI:S:{};T:{};P:{};;", + arguments.ssid, + arguments.encryption.to_uppercase(), + password ); - match generate_qr_code(&wifi_info) { - Ok(qr_code) => { - let renderer: String = qr_code.render::().build(); - let svg_data: String = renderer.to_string(); - - match File::create("qrcode.svg") { - Ok(mut f) => { - f.write_all(svg_data.as_bytes()) - .expect("Error exporting QR code to SVG"); - } - Err(e) => { - eprintln!("Error exporting QR code to SVG: {}", e); - std::process::exit(1); - } - } + let qrcode = QrCode::with_error_correction_level(contents_to_encode.as_bytes(), EcLevel::H)?; + + let image = qrcode + .render() + .min_dimensions(size, size) + .dark_color(svg::Color(foreground)) + .light_color(svg::Color(background)) + .build(); + + match export_format { + "svg" => { + let mut writer = BufWriter::new(File::create(&arguments.output)?); + writer.write_all(image.as_bytes())?; + }, + + "png" => { + unimplemented!() } - Err(e) => { - eprintln!("Error generating QR code: {}", e); - std::process::exit(1); + + _ => { + return Err(anyhow!("Invalid image format: '{}'", export_format)); } } -} + Ok(()) +} From ad1e674acb17791e5f604149c2bdf7c52e636189 Mon Sep 17 00:00:00 2001 From: #84837 Date: Sun, 3 Mar 2024 01:09:11 +0100 Subject: [PATCH 3/7] document configuration --- docs/LICENSE.md | 445 ++++++++++++++++++++++++++++++++++++++++++ docs/configuration.md | 27 +++ 2 files changed, 472 insertions(+) create mode 100644 docs/LICENSE.md create mode 100644 docs/configuration.md diff --git a/docs/LICENSE.md b/docs/LICENSE.md new file mode 100644 index 0000000..05e2ce1 --- /dev/null +++ b/docs/LICENSE.md @@ -0,0 +1,445 @@ +# GNU Free Documentation License + +Version 1.3, 3 November 2008 + +Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, +Inc. + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + +## 0. PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +functional and useful document "free" in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of "copyleft", which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; it +can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + +## 1. APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The "Document", below, refers +to any such manual or work. Any member of the public is a licensee, +and is addressed as "you". You accept the license if you copy, modify +or distribute the work in a way requiring permission under copyright +law. + +A "Modified Version" of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A "Secondary Section" is a named appendix or a front-matter section of +the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall +subject (or to related matters) and contains nothing that could fall +directly within that overall subject. (Thus, if the Document is in +part a textbook of mathematics, a Secondary Section may not explain +any mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The "Invariant Sections" are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The "Cover Texts" are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may be +at most 5 words, and a Back-Cover Text may be at most 25 words. + +A "Transparent" copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not "Transparent" is called "Opaque". + +Examples of suitable formats for Transparent copies include plain +ASCII without markup, Texinfo input format, LaTeX input format, SGML +or XML using a publicly available DTD, and standard-conforming simple +HTML, PostScript or PDF designed for human modification. Examples of +transparent image formats include PNG, XCF and JPG. Opaque formats +include proprietary formats that can be read and edited only by +proprietary word processors, SGML or XML for which the DTD and/or +processing tools are not generally available, and the +machine-generated HTML, PostScript or PDF produced by some word +processors for output purposes only. + +The "Title Page" means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, "Title Page" means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +The "publisher" means any person or entity that distributes copies of +the Document to the public. + +A section "Entitled XYZ" means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as "Acknowledgements", +"Dedications", "Endorsements", or "History".) To "Preserve the Title" +of such a section when you modify the Document means that it remains a +section "Entitled XYZ" according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + +## 2. VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no +other conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + +## 3. COPYING IN QUANTITY + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify you +as the publisher of these copies. The front cover must present the +full title with all words of the title equally prominent and visible. +You may add other material on the covers in addition. Copying with +changes limited to the covers, as long as they preserve the title of +the Document and satisfy these conditions, can be treated as verbatim +copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to +give them a chance to provide you with an updated version of the +Document. + +## 4. MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +- A. Use in the Title Page (and on the covers, if any) a title + distinct from that of the Document, and from those of previous + versions (which should, if there were any, be listed in the + History section of the Document). You may use the same title as a + previous version if the original publisher of that version + gives permission. +- B. List on the Title Page, as authors, one or more persons or + entities responsible for authorship of the modifications in the + Modified Version, together with at least five of the principal + authors of the Document (all of its principal authors, if it has + fewer than five), unless they release you from this requirement. +- C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. +- D. Preserve all the copyright notices of the Document. +- E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. +- F. Include, immediately after the copyright notices, a license + notice giving the public permission to use the Modified Version + under the terms of this License, in the form shown in the + Addendum below. +- G. Preserve in that license notice the full lists of Invariant + Sections and required Cover Texts given in the Document's + license notice. +- H. Include an unaltered copy of this License. +- I. Preserve the section Entitled "History", Preserve its Title, + and add to it an item stating at least the title, year, new + authors, and publisher of the Modified Version as given on the + Title Page. If there is no section Entitled "History" in the + Document, create one stating the title, year, authors, and + publisher of the Document as given on its Title Page, then add an + item describing the Modified Version as stated in the + previous sentence. +- J. Preserve the network location, if any, given in the Document + for public access to a Transparent copy of the Document, and + likewise the network locations given in the Document for previous + versions it was based on. These may be placed in the "History" + section. You may omit a network location for a work that was + published at least four years before the Document itself, or if + the original publisher of the version it refers to + gives permission. +- K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the section all + the substance and tone of each of the contributor acknowledgements + and/or dedications given therein. +- L. Preserve all the Invariant Sections of the Document, unaltered + in their text and in their titles. Section numbers or the + equivalent are not considered part of the section titles. +- M. Delete any section Entitled "Endorsements". Such a section may + not be included in the Modified Version. +- N. Do not retitle any existing section to be Entitled + "Endorsements" or to conflict in title with any Invariant Section. +- O. Preserve any Warranty Disclaimers. + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled "Endorsements", provided it contains +nothing but endorsements of your Modified Version by various +parties—for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + +## 5. COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled "History" +in the various original documents, forming one section Entitled +"History"; likewise combine any sections Entitled "Acknowledgements", +and any sections Entitled "Dedications". You must delete all sections +Entitled "Endorsements". + +## 6. COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other +documents released under this License, and replace the individual +copies of this License in the various documents with a single copy +that is included in the collection, provided that you follow the rules +of this License for verbatim copying of each of the documents in all +other respects. + +You may extract a single document from such a collection, and +distribute it individually under this License, provided you insert a +copy of this License into the extracted document, and follow this +License in all other respects regarding verbatim copying of that +document. + +## 7. AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an "aggregate" if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + +## 8. TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled "Acknowledgements", +"Dedications", or "History", the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + +## 9. TERMINATION + +You may not copy, modify, sublicense, or distribute the Document +except as expressly provided under this License. Any attempt otherwise +to copy, modify, sublicense, or distribute it is void, and will +automatically terminate your rights under this License. + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, receipt of a copy of some or all of the same material does +not give you any rights to use it. + +## 10. FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions of the +GNU Free Documentation License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in +detail to address new problems or concerns. See +. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. If the Document specifies +that a proxy can decide which future versions of this License can be +used, that proxy's public statement of acceptance of a version +permanently authorizes you to choose that version for the Document. + +## 11. RELICENSING + +"Massive Multiauthor Collaboration Site" (or "MMC Site") means any +World Wide Web server that publishes copyrightable works and also +provides prominent facilities for anybody to edit those works. A +public wiki that anybody can edit is an example of such a server. A +"Massive Multiauthor Collaboration" (or "MMC") contained in the site +means any set of copyrightable works thus published on the MMC site. + +"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 +license published by Creative Commons Corporation, a not-for-profit +corporation with a principal place of business in San Francisco, +California, as well as future copyleft versions of that license +published by that same organization. + +"Incorporate" means to publish or republish a Document, in whole or in +part, as part of another Document. + +An MMC is "eligible for relicensing" if it is licensed under this +License, and if all works that were first published under this License +somewhere other than this MMC, and subsequently incorporated in whole +or in part into the MMC, (1) had no cover texts or invariant sections, +and (2) were thus incorporated prior to November 1, 2008. + +The operator of an MMC Site may republish an MMC contained in the site +under CC-BY-SA on the same site at any time before August 1, 2009, +provided the MMC is eligible for relicensing. + +## ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + + Copyright (C) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled "GNU + Free Documentation License". + +If you have Invariant Sections, Front-Cover Texts and Back-Cover +Texts, replace the "with … Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with the + Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, to +permit their use in free software. diff --git a/docs/configuration.md b/docs/configuration.md new file mode 100644 index 0000000..6ba7f9c --- /dev/null +++ b/docs/configuration.md @@ -0,0 +1,27 @@ +# Configuration + +The configuration file should include sections for `qrcode` and `colors` with the following variables. + +|Variable|Description| +|---|---| +|`export`|The format in which the QR code should be exported (`svg` or `png`. default: `svg`)| +|`size`|Defines the dimensions of the QR code. (default: `512`)| +|`password`|Contains the WiFi password. (mandatory)| +|`foreground`|The foreground color of the QR code. (default: white)| +|`background`|The background color of the QR code. (default: black)| + +> [!WARNING] +> Only the SVG format is implemented as of now. + +Here is a sample configuration template: + +```toml +[qrcode] +password = "your_wifi_password" +export = "svg" +size = 512 + +[colors] +background = "#111111" +foreground = "#00d0d0" +``` From cfca2d0ee2a3497a304e0b135ba2ab387e2d2712 Mon Sep 17 00:00:00 2001 From: #84837 Date: Sun, 3 Mar 2024 01:23:11 +0100 Subject: [PATCH 4/7] update deps and clean cargo.lock --- Cargo.lock | 22 +++++++++++----------- Cargo.toml | 8 ++------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a8f1db..61753dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,6 +106,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17cc5e6b5ab06331c33589842070416baa137e8b0eb912b008cfd4a78ada7919" +[[package]] +name = "ciphercanvas-rs" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap 4.5.1", + "qrcode", + "structopt", + "toml", +] + [[package]] name = "clap" version = "2.34.0" @@ -509,17 +520,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "wifi-qrcode-rs" -version = "0.0.3" -dependencies = [ - "anyhow", - "clap 4.5.1", - "qrcode", - "structopt", - "toml", -] - [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 5a6a5f4..7347800 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "wifi-qrcode-rs" -version = "0.0.3" +name = "ciphercanvas-rs" +version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -11,7 +11,3 @@ clap = { version = "4.5.1", features = ["derive"] } qrcode = "0.12" structopt = "0.3" toml = "0.8" -# tempfile = "3.8" -# resvg = "0.36" -# usvg = "0.36" -# tiny-skia = "0.11" From 84c7c75e7b400d26c3acae1192e57347c33673de Mon Sep 17 00:00:00 2001 From: #84837 Date: Sun, 3 Mar 2024 01:27:08 +0100 Subject: [PATCH 5/7] update changelog --- CHANGELOG.md | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50a7333..252e8e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,16 +2,28 @@ All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](https://keepachangelog.com/), -and this project adheres to [Semantic Versioning](https://semver.org/). +The format is based on [Keep a Changelog](https://keepachangelog.com/), and this +project adheres to [Semantic Versioning](https://semver.org/). ## \[Unreleased\] +## \[0.1.0\] - 2024-03-03 + +### Added + + - Add TOML configuration and document it. + +### Changed + + - Change handling from StructOpt to Clap. + - Rename project from `wifi-qrcode-rs` to `ciphercanvas-rs`. + ## \[0.0.2\] - 2023-10-15 ### Added - - Instead of using manual user input, the program will instead take them from command-line arguments, handled by StructOpt. + - Instead of using manual user input, the program will instead take them from + command-line arguments, handled by StructOpt. - Added project files: - CHANGELOG.md - CODE\_OF\_CONDUCT.md @@ -20,28 +32,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/). - Renamed LICENSE to LICENSE.md to reflect the right formatting. -### Changed - - - None. - -### Removed - - - None. - ## \[0.0.1\] - 2023-07-31 ### Added - Initial release of `wifi-qrcode-rs`. - -### Fixed - - - None. - -### Changed - - - None. - -### Removed - - - None. From 37fe502b315eae275a4796ab95b5e92072203814 Mon Sep 17 00:00:00 2001 From: #84837 Date: Sun, 3 Mar 2024 01:27:16 +0100 Subject: [PATCH 6/7] update readme --- README.md | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index f65c329..5e24ceb 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,34 @@ -# wifi-qrcode-rs +# ciphercanvas: wifi qr generator -This is a simple WiFi QR code generator written in Rust. It generates the QR code as an SVG image, allowing easy sharing and scanning of WiFi information. +A program written in Rust that generates a QR code from a WiFi network +configuration file. It takes the SSID, encryption type (WPA or WEP), password, +and desired output format as input, and writes the QR code to the specified +output file. - - [How to Use](#how-to-use) - - [Usage](#usage) +## Table of contents + + - [Usage](#usage) - [Contributing](#contributing) - [License](#license) -## How to Use - -1. Open the program. - -2. Input the WiFi name or SSID, the WiFi password, and the WiFi encryption type (WPA, WEP, or nopass for no password). - -3. The program will generate a `qrcode.svg` SVG image with the provided WiFi information. - -### Usage +## Usage -For generating a WiFi QR code with the program, use the following command: +For generating a WiFi QR code with the program: -```shell -$ ./wifi-qrcode-rs-linux-x86_64 --ssid mywifiname --password iusearchbtw123 --encryption WPA -``` +1. Make a configuration file according to [the + documentation](docs/configuration.md). -This will generate a `qrcode.svg` image with the QR code for the WiFi network. +2. Run `ciphercanvas` to generate the QR code. This will generate a `qrcode.svg` + image with the QR code for the WiFi network. + + ``` console + $ ./ciphercanvas -s wifi4life -e WPA -c your-config-file.toml + ``` ## Contributing -Contributions are welcome\! If you'd like to contribute, please follow this procedure: +Contributions are welcome! If you'd like to contribute, please follow this +procedure: 1. Fork this repository. 2. Clone the forked repository. @@ -36,4 +37,5 @@ Contributions are welcome\! If you'd like to contribute, please follow this proc ## License -This project is licensed under the GNU General Public License version 3.0 (GPLv3). The full version of the license is [here](LICENSE.md). You can obtain a copy [here](https://www.gnu.org/licenses/gpl-3.0.html). +This project is licensed under the [GNU General Public License +version 3.0](LICENSE.md). From c2c4f6ec393cffcf318371fb85c538a76ed23cd2 Mon Sep 17 00:00:00 2001 From: #84837 Date: Sun, 3 Mar 2024 01:27:23 +0100 Subject: [PATCH 7/7] format file --- src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8254fd5..a627182 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,14 +48,20 @@ fn main() -> Result<()> { let toml_config: Value = toml::from_str(&config_str)?; let export_format = toml_config["qrcode"]["export"].as_str().unwrap_or_else(|| { - eprintln!("Found invalid or missing value for output format. Falling back to {:?}...", Consts::FORMAT); + eprintln!( + "Found invalid or missing value for output format. Falling back to {:?}...", + Consts::FORMAT + ); Consts::FORMAT }); let size = toml_config["qrcode"]["size"] .as_str() .unwrap_or_else(|| { - eprintln!("Failed to get size: falling back to {0}x{0}...", Consts::SIZE); + eprintln!( + "Failed to get size: falling back to {0}x{0}...", + Consts::SIZE + ); "512" }) .parse::()?; @@ -113,7 +119,7 @@ fn main() -> Result<()> { "svg" => { let mut writer = BufWriter::new(File::create(&arguments.output)?); writer.write_all(image.as_bytes())?; - }, + } "png" => { unimplemented!()