Skip to content

Commit

Permalink
remove clap
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Aug 14, 2024
1 parent 3f8a4ea commit 21ec823
Show file tree
Hide file tree
Showing 8 changed files with 481 additions and 453 deletions.
6 changes: 2 additions & 4 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ license = "MIT"
repository = "https://github.com/zip-rs/zip2.git"
keywords = ["zip", "archive", "compression", "cli"]
categories = ["command-line-utilities", "compression", "filesystem", "development-tools::build-utils"]
# Keep this up to date with clap!
rust-version = "1.74.0"
description = """
Binary for creation and manipulation of zip files.
Expand All @@ -25,8 +24,7 @@ members = ["."]
name = "zip-cli"

[dependencies]
clap = { version = "4.5.15", features = ["derive"] }
eyre = "0.6"
color-eyre = "0.6"

[dependencies.zip]
path = ".."
Expand All @@ -46,6 +44,7 @@ lzma = ["zip/lzma"]
time = ["zip/time"]
xz = ["zip/xz"]
zstd = ["zip/zstd"]

default = [
"aes-crypto",
"bzip2",
Expand All @@ -58,7 +57,6 @@ default = [
]


# Reduce the size of the zip-cli binary.
[profile.release]
strip = true
lto = true
Expand Down
3 changes: 0 additions & 3 deletions cli/clite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ license = "MIT"
repository = "https://github.com/zip-rs/zip2.git"
keywords = ["zip", "archive", "compression", "cli"]
categories = ["command-line-utilities", "compression", "filesystem", "development-tools::build-utils"]
# Keep this up to date with clap!
rust-version = "1.74.0"
description = """
Binary for creation and manipulation of zip files.
Expand All @@ -23,15 +22,13 @@ members = ["."]
name = "zip-clite"

[dependencies]
clap = { version = "4.5.15", features = ["derive"] }
eyre = "0.6"

[dependencies.zip-cli]
path = ".."
default-features = false
features = ["deflate-flate2", "deflate-zlib"]

# Reduce the size of the zip-cli binary.
[profile.release]
strip = true
lto = true
Expand Down
16 changes: 6 additions & 10 deletions cli/clite/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
use std::env;
use std::io;

use clap::{error::ErrorKind, Parser};
use eyre::Report;

use zip_cli::args::*;
use zip_cli::compress::execute_compress;
use zip_cli::ErrHandle;

fn main() -> Result<(), Report> {
let ZipCli { verbose, command } = match ZipCli::try_parse() {
Ok(args) => args,
Err(e) => match e.kind() {
ErrorKind::Format | ErrorKind::Io | ErrorKind::InvalidUtf8 => return Err(e.into()),
_ => e.exit(),
},
};
let ZipCli { verbose, command } = ZipCli::parse_argv(env::args_os())?;
let mut err = if verbose {
ErrHandle::Output(io::stderr())
} else {
ErrHandle::NoOutput
};

match command {
ZipCommand::Info | ZipCommand::Extract => Ok(()),
ZipCommand::Compress(compress) => execute_compress(&mut err, compress),
ZipCommand::Info => eyre::bail!("info command not implemented"),
ZipCommand::Extract => eyre::bail!("extract command not implemented"),
ZipCommand::Compress(compress) => execute_compress(&mut err, compress)?,
}
Ok(())
}
Loading

0 comments on commit 21ec823

Please sign in to comment.