Skip to content

Commit

Permalink
fix CI/CD workflow error. refactor Format::Unknown and ToteError::Unk…
Browse files Browse the repository at this point in the history
…nownError.
  • Loading branch information
tamada committed May 14, 2024
1 parent e0b5bae commit b31c768
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn create_archiver(dest: &PathBuf) -> Result<Box<dyn Archiver>> {
Format::TarXz => Ok(Box::new(TarXzArchiver {})),
Format::Rar => Ok(Box::new(RarArchiver {})),
Format::SevenZ => Ok(Box::new(SevenZArchiver {})),
_ => Err(ToteError::UnsupportedFormat(format.to_string())),
_ => Err(ToteError::UnknownFormat(format.to_string())),
}
}
Err(msg) => Err(msg),
Expand Down
2 changes: 1 addition & 1 deletion src/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn create_extractor(file: &PathBuf) -> Result<Box<dyn Extractor>> {
Format::TarBz2 => Ok(Box::new(tar::TarBz2Extractor{})),
Format::TarXz => Ok(Box::new(tar::TarXzExtractor{})),
Format::SevenZ => Ok(Box::new(sevenz::SevenZExtractor{})),
Format::Unknown(s) => Err(ToteError::UnsupportedFormat(format!("{}: unsupported format", s))),
Format::Unknown(s) => Err(ToteError::UnknownFormat(format!("{}: unsupported format", s))),
}
}
Err(msg) => Err(msg),
Expand Down
2 changes: 1 addition & 1 deletion src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn find_format(file_name: Option<&OsStr>) -> Result<Format> {
} else if name.ends_with(".zip") || name.ends_with(".jar") || name.ends_with(".war") || name.ends_with(".ear") {
return Ok(Format::Zip);
} else {
return Err(ToteError::UnknownFormat(name.to_string()));
return Ok(Format::Unknown(file_name.to_str().unwrap().to_string()));
}
}
None => Err(ToteError::NoArgumentsGiven),
Expand Down
43 changes: 26 additions & 17 deletions templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,34 @@ The tool can extract archive files and archive files and directories.
## Usage

```sh
totebag [OPTIONS] <ARGUMENTS...>
OPTIONS
-m, --mode <MODE> Mode of operation. available: extract, archive, and auto.
Default is auto.
-d, --dest <DEST> Destination of the extraction results.
Default is the current directory.
-o, --output <FILE> Output file for the archive.
Default is the totebag.zip.
The archive formats are guessed form extension of the file name.
--overwrite Overwrite the output file if it exists.
-v, --verbose Display verbose output.
-h, --help Display this help message.
ARGUMENTS
extract mode: archive files to be extracted.
archive mode: files to be archived.
auto mode: if the arguments have archive files, it will extract them.
Otherwise, it will archive the files.
A tool for archiving files and directories and extracting several archive formats.

Usage: totebag [OPTIONS] [ARGUMENTS]...

Arguments:
[ARGUMENTS]... List of files or directories to be processed.

Options:
-m, --mode <MODE> Mode of operation. [default: auto] [possible values: auto, archive, extract, list]
-o, --output <DEST> Output file in archive mode, or output directory in extraction mode
--to-archive-name-dir extract files to DEST/ARCHIVE_NAME directory (extract mode).
-n, --no-recursive No recursive directory (archive mode).
-v, --verbose Display verbose output.
--overwrite Overwrite existing files.
-h, --help Print help
-V, --version Print version
```

Supported archive formats:

- Tar
- Tar+Gzip
- Tar+Bzip2
- Tar+Xz
- Zip
- 7z
- Rar (extraction only)

## Install

```sh
Expand Down

0 comments on commit b31c768

Please sign in to comment.