-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f8a4ea
commit ff8898a
Showing
8 changed files
with
479 additions
and
453 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |
Oops, something went wrong.