use crate::steganography::StegMethod;
use anyhow::{bail, Result};
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(StructOpt)]
#[structopt(name = "🦕 stegosaurust", about = "Hide text in images, using rust.")]
pub struct Opt {
#[structopt(short, long)]
pub decode: bool,
#[structopt(short, long)]
pub base64: bool,
#[structopt(short, long)]
pub compress: bool,
#[structopt(short, long)]
pub key: Option<String>,
#[structopt(short = "C", long)]
pub check_max_length: bool,
#[structopt(short, long, default_value = "lsb")]
pub method: StegMethod,
#[structopt(short, long, required_if("method", "rsb"))]
pub seed: Option<String>,
#[structopt(short = "N", long, required_if("method", "rsb"))]
pub max_bit: Option<u8>,
#[structopt(short, long, parse(from_os_str))]
pub output: Option<PathBuf>,
#[structopt(short, long, parse(from_os_str), conflicts_with = "decode")]
pub input: Option<PathBuf>,
#[structopt(parse(from_os_str))]
pub image: PathBuf,
}
impl Opt {
pub fn validate(&self) -> Result<()> {
if let Some(n) = self.max_bit {
if !(1..=4).contains(&n) {
bail!(format!("max-bit must be between 1-4. Got {}", n))
}
}
Ok(())
}
}