Compare commits

..

No commits in common. "7caf914a26be9e0e9303abf7dd414f1a818bdd2f" and "75102014fc214b7f1d2133ab34fff31047529430" have entirely different histories.

5 changed files with 2 additions and 144 deletions

54
Cargo.lock generated
View File

@ -58,7 +58,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
@ -73,18 +72,6 @@ dependencies = [
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.7.2"
@ -112,12 +99,6 @@ version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
@ -132,47 +113,12 @@ dependencies = [
"crc",
]
[[package]]
name = "proc-macro2"
version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
dependencies = [
"proc-macro2",
]
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "2.0.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
[[package]]
name = "utf8parse"
version = "0.2.2"

View File

@ -5,4 +5,4 @@ edition = "2021"
[dependencies]
crc = "3.2.1"
clap = { version = "4.5.20", features = ["derive"] }
clap = "4.5.20"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 KiB

View File

@ -1,39 +0,0 @@
use clap::{Parser, ValueEnum};
#[derive(Parser, Debug)]
#[command(version, about)]
pub struct Args {
#[arg(long, value_enum, required = true)]
pub mode: Mode,
#[arg(
short,
long,
required = true,
)]
pub input_file: Option<String>,
#[arg(
short,
long,
required_if_eq("mode", "Mode::Encode"),
required_if_eq("mode", "Mode::Decode"),
required_if_eq("mode", "Mode::Remove")
)]
pub chunk_type: Option<String>,
#[arg(
short,
long,
required_if_eq("mode", "Mode::Encode")
)]
pub message: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
pub enum Mode {
Encode,
Decode,
Print,
Remove
}

View File

@ -4,58 +4,9 @@ mod chunk_type;
mod commands;
mod png;
use core::panic;
use std::path::PathBuf;
use std::fs::File;
use args::Mode;
use chunk_type::ChunkType;
use clap::Parser;
use crate::args::Args;
pub type Error = Box<dyn std::error::Error>;
pub type Result<T> = std::result::Result<T, Error>;
fn get_image(path: &str) -> File {
let image_path: PathBuf = PathBuf::from(path);
let path_display = image_path.display();
let image = match File::open(&image_path) {
Err(why) => panic!("couldn't open {}: {}", path_display, why),
Ok(file) => file
};
image
}
fn encode(image: File, chunk_type: ChunkType, message: &str) {
todo!()
}
fn decode(image: File, chunk_type: ChunkType) {
todo!()
}
fn print_message(image: File) {
todo!()
}
fn remove_message(image: File, chunk_type: ChunkType) {
todo!()
}
fn main() -> Result<()> {
let args = Args::parse();
let image = get_image(&args.input_file.unwrap());
match args.mode {
Mode::Encode => todo!(),
Mode::Decode => todo!(),
Mode::Print => todo!(),
Mode::Remove => todo!(),
_ => Err("not a valid mode")?
}
Ok(())
todo!()
}