Skip to content

Commit

Permalink
parse the whole command line without clap
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Aug 14, 2024
1 parent d588c1b commit 1f7d0a1
Show file tree
Hide file tree
Showing 6 changed files with 492 additions and 38 deletions.
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ name = "zip-cli"

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

[dependencies.zip]
path = ".."
Expand Down
10 changes: 6 additions & 4 deletions cli/clite/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::io;
#[cfg(not(feature = "clap"))]
use std::env;
use std::io;

#[cfg(feature = "clap")]
use clap::{error::ErrorKind, Parser};
Expand All @@ -15,7 +15,7 @@ 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()),
ErrorKind::Format | ErrorKind::Io => return Err(e.into()),
_ => e.exit(),
},
};
Expand All @@ -28,7 +28,9 @@ fn main() -> Result<(), Report> {
};

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 1f7d0a1

Please sign in to comment.