Skip to content

Commit

Permalink
qr code maker
Browse files Browse the repository at this point in the history
  • Loading branch information
jRimbault committed Jan 14, 2024
1 parent 8bf6f75 commit c4cd262
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
41 changes: 39 additions & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions qr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ clap-verbosity-flag = "2.1.1"
env_logger = "0.10.1"
image = "0.24.7"
log = "0.4.20"
open = "5.0.1"
qrcode = "0.13.0"
15 changes: 12 additions & 3 deletions qr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ struct Args {
/// Output directory
#[arg(short, long, default_value = env!("CARGO_BIN_NAME"))]
out: PathBuf,
/// Open the QR codes automatically with your configured image viewer
#[arg(long)]
open: bool,
#[command(flatten)]
verbose: Verbosity<WarnLevel>,
}
Expand Down Expand Up @@ -42,11 +45,17 @@ fn main() -> Result<()> {
});
let out = &args.out;
std::fs::create_dir_all(out)?;
let mut images = Vec::new();
for (name, image) in receiver {
image
.save(out.join(&name))
.context(format!("writing {name:?}"))?;
let path = out.join(&name);
image.save(&path).context(format!("writing {name:?}"))?;
log::info!("saved {name:?} to {out:?}");
if args.open {
images.push(path);
}
}
for image in images {
open::that_detached(image)?;
}
Ok(())
})
Expand Down

0 comments on commit c4cd262

Please sign in to comment.