added help and splash message

rust
Avril 3 years ago
parent 114472559e
commit 39607dc97c
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -15,14 +15,17 @@ opt-level = 1
opt-level = 1
[features]
default = ["deferred-drop"]
default = ["splash", "deferred-drop"]
# Print name and info when printing help info
splash = []
# Move large objects to a seperate thread to be dropped.
deferred-drop = ["lazy_static"]
deferred-drop = []
[dependencies]
cfg-if = "1.0.0"
lazy_static = {version = "1.4.0", optional = true}
lazy_static = "1.4.0"
rand = "0.8.3"
[dev-dependencies]

@ -0,0 +1,38 @@
/// The executable program name
pub fn program_name() -> &'static str
{
lazy_static! {
static ref NAME: String = std::env::args().next().unwrap();
}
&NAME[..]
}
#[cfg(feature="splash")]
#[inline] fn splash()
{
println!("shuffle3rs (v{}) - improved 3 pass binary shuffler (Rust ver)", env!("CARGO_PKG_VERSION"));
println!(" written by {} with <3", env!("CARGO_PKG_AUTHORS"));
println!(" licensed with GPL v3.0 or later\n");
}
/// Print usage message
pub fn usage()
{
#[cfg(feature="splash")] splash();
println!("Usage: {} -s <file>", program_name());
println!("Usage: {} -u <file>", program_name());
println!("\nOPTIONS:");
println!(" -s\tShuffle file in place");
println!(" -u\tUnshuffle file in place");
}
/// Print usage message and then exit with error code `2`.
#[inline] pub fn help() -> !
{
usage();
std::process::exit(2)
}

@ -8,11 +8,11 @@
#[cfg(feature="deferred-drop")] mod defer_drop;
mod shuffle;
mod arg;
fn main() {
println!("Hello, world!");
arg::help();
}
#[cfg(test)] mod test;

Loading…
Cancel
Save