mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
New --help message
This commit is contained in:
parent
973af5fe1c
commit
df1bc879cb
@ -14,6 +14,7 @@ description = "A command-line utility for easily compressing and decompressing f
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
colored = "2.0.0"
|
colored = "2.0.0"
|
||||||
|
termion = "1.5.6"
|
||||||
walkdir = "2.3.2"
|
walkdir = "2.3.2"
|
||||||
tar = "0.4.33"
|
tar = "0.4.33"
|
||||||
xz2 = "0.1.6"
|
xz2 = "0.1.6"
|
||||||
|
@ -38,28 +38,12 @@ pub fn run(command: Command, flags: &oof::Flags) -> crate::Result<()> {
|
|||||||
decompress_file(file, output_folder, flags)?;
|
decompress_file(file, output_folder, flags)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command::ShowHelp => help_command(),
|
Command::ShowHelp => crate::help_command(),
|
||||||
Command::ShowVersion => version_command(),
|
Command::ShowVersion => crate::version_command(),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn help_command() {
|
|
||||||
version_command();
|
|
||||||
println!("Vinícius R. M. & João M. Bezerra");
|
|
||||||
println!("ouch is a unified compression & decompression utility");
|
|
||||||
println!();
|
|
||||||
println!(" COMPRESSION USAGE:");
|
|
||||||
println!(" ouch compress <input...> output-file");
|
|
||||||
println!("DECOMPRESSION USAGE:");
|
|
||||||
println!(" ouch <input> [-o/--output output-folder]");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn version_command() {
|
|
||||||
println!("ouch {}", crate::VERSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
type BoxedCompressor = Box<dyn Compressor>;
|
type BoxedCompressor = Box<dyn Compressor>;
|
||||||
type BoxedDecompressor = Box<dyn Decompressor>;
|
type BoxedDecompressor = Box<dyn Decompressor>;
|
||||||
|
|
||||||
|
67
src/lib.rs
67
src/lib.rs
@ -11,6 +11,71 @@ mod extension;
|
|||||||
mod file;
|
mod file;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
|
pub use error::{Error, Result};
|
||||||
|
|
||||||
const VERSION: &str = "0.1.5";
|
const VERSION: &str = "0.1.5";
|
||||||
|
|
||||||
pub use error::{Error, Result};
|
fn help_command() {
|
||||||
|
use utils::colors::*;
|
||||||
|
/*
|
||||||
|
ouch - Obvious Unified Compressed files Helper
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
ouch <files...> Decompresses files.
|
||||||
|
|
||||||
|
ouch compress <files...> OUTPUT.EXT Compresses files into OUTPUT.EXT,
|
||||||
|
where EXT must be a supported format.
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
-h, --help Display this help information.
|
||||||
|
-y, --yes Skip overwrite questions.
|
||||||
|
-n, --no Skip overwrite questions.
|
||||||
|
--version Display version information.
|
||||||
|
|
||||||
|
SPECIFIC FLAGS:
|
||||||
|
-o, --output FOLDER_PATH When decompressing, to decompress files to
|
||||||
|
another folder.
|
||||||
|
|
||||||
|
Visit https://github.com/vrmiguel/ouch for more usage examples.
|
||||||
|
*/
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"\
|
||||||
|
{cyan}ouch{reset} - Obvious Unified Compression files Helper
|
||||||
|
|
||||||
|
{cyan}USAGE:{reset}
|
||||||
|
{green}ouch {magenta}<files...>{reset} Decompresses files.
|
||||||
|
|
||||||
|
{green}ouch compress {magenta}<files...> OUTPUT.EXT{reset} Compresses files into {magenta}OUTPUT.EXT{reset},
|
||||||
|
where {magenta}EXT{reset} must be a supported format.
|
||||||
|
|
||||||
|
{cyan}FLAGS:{reset}
|
||||||
|
{yellow}-h{white}, {yellow}--help{reset} Display this help information.
|
||||||
|
{yellow}-y{white}, {yellow}--yes{reset} Skip overwrite questions.
|
||||||
|
{yellow}-n{white}, {yellow}--no{reset} Skip overwrite questions.
|
||||||
|
{yellow}--version{reset} Display version information.
|
||||||
|
|
||||||
|
{cyan}SPECIFIC FLAGS:{reset}
|
||||||
|
{yellow}-o{reset}, {yellow}--output{reset} FOLDER_PATH When decompressing, to decompress files to
|
||||||
|
another folder.
|
||||||
|
|
||||||
|
Visit https://github.com/vrmiguel/ouch for more usage examples.",
|
||||||
|
magenta = magenta(),
|
||||||
|
white = white(),
|
||||||
|
green = green(),
|
||||||
|
yellow = yellow(),
|
||||||
|
reset = reset(),
|
||||||
|
cyan = cyan()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn version_command() {
|
||||||
|
use utils::colors::*;
|
||||||
|
println!(
|
||||||
|
"{green}ouch{reset} {}",
|
||||||
|
crate::VERSION,
|
||||||
|
green = green(),
|
||||||
|
reset = reset(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
33
src/utils.rs
33
src/utils.rs
@ -126,6 +126,39 @@ pub struct Bytes {
|
|||||||
bytes: f64,
|
bytes: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub mod colors {
|
||||||
|
use termion::color::*;
|
||||||
|
|
||||||
|
pub fn reset() -> &'static str {
|
||||||
|
Reset.fg_str()
|
||||||
|
}
|
||||||
|
pub fn black() -> &'static str {
|
||||||
|
LightBlack.fg_str()
|
||||||
|
}
|
||||||
|
pub fn blue() -> &'static str {
|
||||||
|
LightBlue.fg_str()
|
||||||
|
}
|
||||||
|
pub fn cyan() -> &'static str {
|
||||||
|
LightCyan.fg_str()
|
||||||
|
}
|
||||||
|
pub fn green() -> &'static str {
|
||||||
|
LightGreen.fg_str()
|
||||||
|
}
|
||||||
|
pub fn magenta() -> &'static str {
|
||||||
|
LightMagenta.fg_str()
|
||||||
|
}
|
||||||
|
pub fn red() -> &'static str {
|
||||||
|
LightRed.fg_str()
|
||||||
|
}
|
||||||
|
pub fn white() -> &'static str {
|
||||||
|
LightWhite.fg_str()
|
||||||
|
}
|
||||||
|
pub fn yellow() -> &'static str {
|
||||||
|
LightYellow.fg_str()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Bytes {
|
impl Bytes {
|
||||||
const UNIT_PREFIXES: [&'static str; 6] = ["", "k", "M", "G", "T", "P"];
|
const UNIT_PREFIXES: [&'static str; 6] = ["", "k", "M", "G", "T", "P"];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user