1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use std::path::PathBuf;
use structopt::StructOpt;

/// Command line program that lets you hide secret messages in PNG files.
#[derive(Debug, StructOpt)]
#[structopt(name = "pngme")]
pub struct Opt {
    /// Path to file
    #[structopt(parse(from_os_str))]
    pub input: PathBuf,
    /// Available commands
    #[structopt(subcommand)]
    pub commands: Commands,
}

#[derive(Debug, StructOpt)]
pub enum Commands {
    /// Encodes a message into a PNG file and saves the result
    Encode(EncodeArgs),
    /// Searches for a message hidden in a PNG file and prints the message if one is found
    Decode(DecodeArgs),
    /// Removes a chunk from a PNG file and saves the result
    Remove(RemoveArgs),
    /// Prints all of the chunks in a PNG file
    Print(PrintArgs),
}

#[derive(Debug, StructOpt)]
pub struct EncodeArgs {
    /// Chunk type
    pub chunk_type: String,
    /// Secret message
    pub message: String,
}

#[derive(Debug, StructOpt)]
pub struct DecodeArgs {
    /// Chunk type
    pub chunk_type: String,
}

#[derive(Debug, StructOpt)]
pub struct RemoveArgs {
    /// Chunk type
    pub chunk_type: String,
}

#[derive(Debug, StructOpt)]
pub struct PrintArgs {}