diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index f2c9452..ab53bfd 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -66,7 +66,6 @@ jobs: artifact_name: ${{ needs.setup.outputs.appname }} asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_darwin_arm64 - steps: # initialization - name: Checkout the project diff --git a/.github/workflows/update-version.yaml b/.github/workflows/update-version.yaml index fa795f8..0a33c19 100644 --- a/.github/workflows/update-version.yaml +++ b/.github/workflows/update-version.yaml @@ -31,7 +31,6 @@ jobs: git config --global user.email "action@github.com" auth_header="$(git config --local --get http.https://github.com/.extraheader)" - - name: Commit the changes run: | git commit -a -m "update version to ${{ steps.vars.outputs.tag }}, ready to publish v${{ steps.vars.outputs.tag }}" || true diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e69de29 diff --git a/Cargo.toml b/Cargo.toml index f86fa1d..3d47ce6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "totebag" -version = "0.4.6" +version = "0.5.0" description = "A tool for extracting/archiving files and directories in multiple formats." repository = "https://github.com/tamada/totebag" readme = "README.md" diff --git a/Dockerfile b/Dockerfile index f98731b..fa3a101 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:3.16 AS builder -ARG VERSION=0.4.6 +ARG VERSION=0.5.0 ARG TARGETPLATFORM ARG PLATFORM=${TARGETPLATFORM#linux/} @@ -12,7 +12,7 @@ RUN apk add --no-cache curl tar gzip \ FROM alpine:3.16 -ARG VERSION=0.4.6 +ARG VERSION=0.5.0 LABEL org.opencontainers.image.source https://github.com/tamada/totebag diff --git a/README.md b/README.md index 6067a68..4bf73c8 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ # totebag -[![Version](https://shields.io/badge/Version-0.4.6-blue)](https://github.com/tamada/totebag/releases/tag/v0.4.6) +[![Version](https://shields.io/badge/Version-0.5.0-blue)](https://github.com/tamada/totebag/releases/tag/v0.5.0) [![MIT License](https://shields.io/badge/License-MIT-blue)](https://github.com/tamada/totebag/blob/main/LICENSE) -[![docker](https://shields.io/badge/Docker-0.4.6-blue?logo=docker)](https://github.com/tamada/totebag/pkgs/container/totebag) +[![docker](https://shields.io/badge/Docker-0.5.0-blue?logo=docker)](https://github.com/tamada/totebag/pkgs/container/totebag) [![build](https://github.com/tamada/totebag/actions/workflows/build.yaml/badge.svg)](https://github.com/tamada/totebag/actions/workflows/build.yaml) [![Rust Report Card](https://rust-reportcard.xuri.me/badge/github.com/tamada/totebag)](https://rust-reportcard.xuri.me/report/github.com/tamada/totebag) [![Coverage Status](https://coveralls.io/repos/github/tamada/totebag/badge.svg)](https://coveralls.io/github/tamada/totebag) -A tool for archiving files and directories and extracting several archive formats. +A tool for extracting/archiving files and directories in multiple formats. -## Description +## :speaking_head: Description There are many archive formats and their tools. The one problem with using each tool is that its interfaces are slightly different. Then, The `totebag` treats the archive files as the same interface. @@ -19,7 +19,7 @@ The tool can extract archive files and archive files and directories. ## Usage ```sh -A tool for archiving files and directories and extracting several archive formats. +A tool for extracting/archiving files and directories in multiple formats. Usage: totebag [OPTIONS] [ARGUMENTS]... @@ -43,8 +43,10 @@ Supported archive formats: - Tar+Gzip - Tar+Bzip2 - Tar+Xz +- Tar+Zstd - Zip - 7z +- Lha, Lzh (extraction only) - Rar (extraction only) ## Install @@ -56,7 +58,7 @@ brew install tamada/tap/totebag ## :whale: Docker ```sh -docker run -it --rm -v $PWD:/workdir ghcr.io/tamada/totebag:0.4.6 [OPTIONS] [ARGUMENTS]... +docker run -it --rm -v $PWD:/workdir ghcr.io/tamada/totebag:0.5.0 [OPTIONS] [ARGUMENTS]... ``` - **Working directory**: `/workdir` @@ -76,3 +78,8 @@ From this, I chose the name of the tool, totebag, as a tool for packing files an ![logo](site/assets/logo.jpeg) This logo was generated by [Bing Image Creator](https://www.bing.com/images/create/e4b880e381a4e381aee3828ae38293e38194e38292e78987e6898be381a7e6bdb0e38199e794b7e381aee6898be3818ce68f8fe3818be3828ce3819fe38388e383bce38388e38390e38383e382b0e381aee58699e79c9f/1-6614ce41dd1c44aeae12e06dec2e8d68?id=W4JmwP3BnK41FZKKFPisSw%3d%3d&view=detailv2&idpp=genimg&thId=OIG3.H3M7RnPEDRZaxzpZJuii&FORM=GCRIDP&ajaxhist=0&ajaxserp=0). + +## Related Tools + +- [magiclen/xcompress](https://github.com/magiclen/xcompress) + - XCompress is a free file archiver utility on Linux, providing multi-format archiving to and extracting from ZIP, Z, GZIP, BZIP2, LZ, XZ, LZMA, 7ZIP, TAR, RAR and ZSTD. diff --git a/dockers/alpine/Dockerfile b/dockers/alpine/Dockerfile new file mode 100644 index 0000000..f98731b --- /dev/null +++ b/dockers/alpine/Dockerfile @@ -0,0 +1,29 @@ +FROM alpine:3.16 AS builder + +ARG VERSION=0.4.6 +ARG TARGETPLATFORM +ARG PLATFORM=${TARGETPLATFORM#linux/} + +WORKDIR /home/totebag + +RUN apk add --no-cache curl tar gzip \ + && curl -LO https://github.com/tamada/totebag/releases/download/v${VERSION}/totebag-${VERSION}_linux_${PLATFORM}.tar.gz \ + && tar xvfz totebag-${VERSION}_linux_${PLATFORM}.tar.gz + +FROM alpine:3.16 + +ARG VERSION=0.4.6 + +LABEL org.opencontainers.image.source https://github.com/tamada/totebag + +RUN apk add --no-cache libgcc musl-dev \ + && adduser -D nonroot \ + && mkdir -p /workdir + +COPY --from=builder /home/totebag/totebag-${VERSION}/totebag /opt/totebag/totebag + +WORKDIR /workdir +USER nonroot + +ENTRYPOINT [ "/opt/totebag/totebag" ] + diff --git a/dockers/distroless/Dockerfile b/dockers/distroless/Dockerfile new file mode 100644 index 0000000..114fa64 --- /dev/null +++ b/dockers/distroless/Dockerfile @@ -0,0 +1,22 @@ +FROM rust:latest AS builder + +ARG VERSION=0.4.6 +ARG TARGETPLATFORM + +WORKDIR /work/totebag + +COPY . . +RUN cargo build --release + +FROM gcr.io/distroless/cc + +ARG VERSION=0.4.6 + +LABEL org.opencontainers.image.source https://github.com/tamada/totebag + +COPY --from=builder /work/totebag/target/release/totebag /opt/totebag/totebag + +WORKDIR /workdir +USER nonroot + +ENTRYPOINT [ "/opt/totebag/totebag" ] diff --git a/site/.gitignore b/docs/.gitignore similarity index 100% rename from site/.gitignore rename to docs/.gitignore diff --git a/site/assets/_1d56f772-71bc-4b0d-983f-330a44313cc1.jpeg b/docs/assets/_1d56f772-71bc-4b0d-983f-330a44313cc1.jpeg similarity index 100% rename from site/assets/_1d56f772-71bc-4b0d-983f-330a44313cc1.jpeg rename to docs/assets/_1d56f772-71bc-4b0d-983f-330a44313cc1.jpeg diff --git a/site/assets/_30457128-d703-4d08-943e-8d1479f3028f.jpeg b/docs/assets/_30457128-d703-4d08-943e-8d1479f3028f.jpeg similarity index 100% rename from site/assets/_30457128-d703-4d08-943e-8d1479f3028f.jpeg rename to docs/assets/_30457128-d703-4d08-943e-8d1479f3028f.jpeg diff --git a/site/assets/_7059b774-9f4d-477e-b488-e672f236e955.jpeg b/docs/assets/_7059b774-9f4d-477e-b488-e672f236e955.jpeg similarity index 100% rename from site/assets/_7059b774-9f4d-477e-b488-e672f236e955.jpeg rename to docs/assets/_7059b774-9f4d-477e-b488-e672f236e955.jpeg diff --git a/docs/assets/authors/harry.png b/docs/assets/authors/harry.png new file mode 100644 index 0000000..0f843a3 Binary files /dev/null and b/docs/assets/authors/harry.png differ diff --git a/site/assets/logo.jpeg b/docs/assets/logo.jpeg similarity index 100% rename from site/assets/logo.jpeg rename to docs/assets/logo.jpeg diff --git a/docs/config/_default/hugo.toml b/docs/config/_default/hugo.toml new file mode 100644 index 0000000..ddff151 --- /dev/null +++ b/docs/config/_default/hugo.toml @@ -0,0 +1,5 @@ +baseURL = "https://tamada.github.io/totebag/" +defaultContentLanguage = "en" +languageCode = "en" +enableEmoji = true +math = true diff --git a/docs/config/_default/language.en.toml b/docs/config/_default/language.en.toml new file mode 100644 index 0000000..e69de29 diff --git a/docs/config/_default/module.toml b/docs/config/_default/module.toml new file mode 100644 index 0000000..23b0791 --- /dev/null +++ b/docs/config/_default/module.toml @@ -0,0 +1,2 @@ +[[imports]] +path = "github.com/maolonglong/hugo-simple" diff --git a/docs/config/_default/params.toml b/docs/config/_default/params.toml new file mode 100644 index 0000000..e69de29 diff --git a/docs/content/_index.md b/docs/content/_index.md new file mode 100644 index 0000000..0348ac6 --- /dev/null +++ b/docs/content/_index.md @@ -0,0 +1,25 @@ +--- +menus: ["main"] +title: "🏠 totebag" +weight: 1 +date: 2024-06-11 +--- + +[![Version](https://shields.io/badge/Version-0.4.6-blue)](https://github.com/tamada/totebag/releases/tag/v0.4.6) +[![MIT License](https://shields.io/badge/License-MIT-blue)](https://github.com/tamada/totebag/blob/main/LICENSE) +[![docker](https://shields.io/badge/Docker-0.4.6-blue?logo=docker)](https://github.com/tamada/totebag/pkgs/container/totebag) + +[![build](https://github.com/tamada/totebag/actions/workflows/build.yaml/badge.svg)](https://github.com/tamada/totebag/actions/workflows/build.yaml) +[![Rust Report Card](https://rust-reportcard.xuri.me/badge/github.com/tamada/totebag)](https://rust-reportcard.xuri.me/report/github.com/tamada/totebag) +[![Coverage Status](https://coveralls.io/repos/github/tamada/totebag/badge.svg)](https://coveralls.io/github/tamada/totebag) + +## :speaking_head: Desctiption + +There are many archive formats and their tools. The one problem with using each tool is that its interfaces are slightly different. +Then, The `totebag` treats the archive files as the same interface. +The tool can extract archive files and archive files and directories. + +- [:anchor: Install](install) +- [:running_woman: Usage](usage) +- [:smile: About](about) + diff --git a/docs/content/about.md b/docs/content/about.md new file mode 100644 index 0000000..815bfcd --- /dev/null +++ b/docs/content/about.md @@ -0,0 +1,26 @@ +--- +menus: ["main"] +title: "😀 About" +weight: 100 +date: 2024-06-11 +--- + +## About + +### Authors + +* Haruaki Tamada ([tamada](https://github.com/tamada/)) + +### The Logo and the Origin of totebag + +The general word, totebag, is a bag for carrying things. +From this, I chose the name of the tool, totebag, as a tool for packing files and directories carelessly. + +![logo](/totebag/logo.jpeg) + +This logo was generated by [Bing Image Creator](https://www.bing.com/images/create/e4b880e381a4e381aee3828ae38293e38194e38292e78987e6898be381a7e6bdb0e38199e794b7e381aee6898be3818ce68f8fe3818be3828ce3819fe38388e383bce38388e38390e38383e382b0e381aee58699e79c9f/1-6614ce41dd1c44aeae12e06dec2e8d68?id=W4JmwP3BnK41FZKKFPisSw%3d%3d&view=detailv2&idpp=genimg&thId=OIG3.H3M7RnPEDRZaxzpZJuii&FORM=GCRIDP&ajaxhist=0&ajaxserp=0). + +## Related Tools + +- [magiclen/xcompress](https://github.com/magiclen/xcompress) + - XCompress is a free file archiver utility on Linux, providing multi-format archiving to and extracting from ZIP, Z, GZIP, BZIP2, LZ, XZ, LZMA, 7ZIP, TAR, RAR and ZSTD. diff --git a/docs/content/install.md b/docs/content/install.md new file mode 100644 index 0000000..504d05b --- /dev/null +++ b/docs/content/install.md @@ -0,0 +1,26 @@ +--- +menus: ["main"] +title: "⚓️ Install" +weight: 20 +date: 2024-06-11 +--- + +## :beer: Homebrew + +```sh +brew install tamada/tap/totebag +``` + +## Download + +Download the suitable binary from the [release page](https://github.com/tamada/totebag/releases/latest). +Then, the unpack the downloaded archive and put the binary to the directory in the `PATH`. + +## :whale: Docker + +```sh +docker run -it --rm -v $PWD:/workdir ghcr.io/tamada/totebag:$VERSION [OPTIONS] [ARGUMENTS]... +``` + +- **Working directory**: `/workdir` +- **User**: `nonroot` diff --git a/docs/content/usage.md b/docs/content/usage.md new file mode 100644 index 0000000..f0a211b --- /dev/null +++ b/docs/content/usage.md @@ -0,0 +1,37 @@ +--- +menus: ["main"] +title: "🏃‍♀️ Usage" +weight: 40 +date: 2024-06-11 +--- + +```sh +A tool for extracting/archiving files and directories in multiple formats. + +Usage: totebag [OPTIONS] [ARGUMENTS]... + +Arguments: + [ARGUMENTS]... List of files or directories to be processed. + +Options: + -m, --mode Mode of operation. [default: auto] [possible values: auto, archive, extract, list] + -o, --output 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 +- Tar+Zstd +- Zip +- 7z +- Lha, Lzh (extraction only) +- Rar (extraction only) \ No newline at end of file diff --git a/docs/go.mod b/docs/go.mod new file mode 100644 index 0000000..603fbf7 --- /dev/null +++ b/docs/go.mod @@ -0,0 +1,5 @@ +module github.com/tamada/totebag + +go 1.22.4 + +require github.com/maolonglong/hugo-simple v0.0.0-20240614140236-133917cadf69 // indirect diff --git a/docs/go.sum b/docs/go.sum new file mode 100644 index 0000000..ef7a7ce --- /dev/null +++ b/docs/go.sum @@ -0,0 +1,2 @@ +github.com/maolonglong/hugo-simple v0.0.0-20240614140236-133917cadf69 h1:wy6ctoFp7SrEyI/A0UGzVocdn19baP1nCzvmcbAavso= +github.com/maolonglong/hugo-simple v0.0.0-20240614140236-133917cadf69/go.mod h1:RCoYRfX65nAcc7yY8C5Xn3ynVroBIY//UHa2wcJpQtw= diff --git a/src/archiver.rs b/src/archiver.rs index caeb987..5d21a0a 100644 --- a/src/archiver.rs +++ b/src/archiver.rs @@ -116,13 +116,13 @@ impl ArchiverOpts { if let Some(parent) = p.parent() { if !parent.exists() { if let Err(e) = create_dir_all(parent) { - return Err(ToteError::IOError(e)); + return Err(ToteError::IO(e)); } } } match File::create(self.dest.as_path()) { Ok(f) => Ok(f), - Err(e) => Err(ToteError::IOError(e)), + Err(e) => Err(ToteError::IO(e)), } } } diff --git a/src/archiver/sevenz.rs b/src/archiver/sevenz.rs index 8213372..9ce669d 100644 --- a/src/archiver/sevenz.rs +++ b/src/archiver/sevenz.rs @@ -28,7 +28,7 @@ fn process_file(szw: &mut SevenZWriter, target: PathBuf) -> Result<()> { SevenZArchiveEntry::from_path(&target, name.to_string()), Some(File::open(target).unwrap()), ) { - return Err(ToteError::ArchiverError(e.to_string())); + return Err(ToteError::Archiver(e.to_string())); } Ok(()) } @@ -61,7 +61,7 @@ fn write_sevenz_impl( } } if let Err(e) = szw.finish() { - return Err(ToteError::ArchiverError(e.to_string())); + return Err(ToteError::Archiver(e.to_string())); } Ok(()) } @@ -69,7 +69,7 @@ fn write_sevenz_impl( fn write_sevenz(dest: File, targets: Vec, recursive: bool) -> Result<()> { match SevenZWriter::new(dest) { Ok(write) => write_sevenz_impl(write, targets, recursive), - Err(e) => Err(ToteError::ArchiverError(e.to_string())), + Err(e) => Err(ToteError::Archiver(e.to_string())), } } diff --git a/src/archiver/tar.rs b/src/archiver/tar.rs index 6d37f42..ccc2842 100644 --- a/src/archiver/tar.rs +++ b/src/archiver/tar.rs @@ -90,14 +90,14 @@ fn write_tar_impl(file: W, targets: Vec, recursive: bool) -> } } if let Err(e) = builder.finish() { - return Err(ToteError::ArchiverError(e.to_string())) + return Err(ToteError::Archiver(e.to_string())) } Ok(()) } fn process_dir(builder: &mut Builder, target: PathBuf, recursive: bool) -> Result<()> { if let Err(e) = builder.append_dir(&target, &target) { - return Err(ToteError::ArchiverError(e.to_string())) + return Err(ToteError::Archiver(e.to_string())) } for entry in target.read_dir().unwrap() { if let Ok(e) = entry { @@ -114,7 +114,7 @@ fn process_dir(builder: &mut Builder, target: PathBuf, recursive: b fn process_file(builder: &mut Builder, target: PathBuf) -> Result<()> { if let Err(e) = builder.append_path(target) { - Err(ToteError::ArchiverError(e.to_string())) + Err(ToteError::Archiver(e.to_string())) } else { Ok(()) } diff --git a/src/archiver/zip.rs b/src/archiver/zip.rs index 3dcea3c..8300697 100644 --- a/src/archiver/zip.rs +++ b/src/archiver/zip.rs @@ -49,11 +49,11 @@ fn process_file (zw: &mut ZipWriter, target: PathBuf) -> Result let name = target.to_str().unwrap(); let opts = create(&target); if let Err(e) = zw.start_file(name, opts) { - return Err(ToteError::ArchiverError(e.to_string())); + return Err(ToteError::Archiver(e.to_string())); } let mut file = BufReader::new(File::open(target).unwrap()); if let Err(e) = std::io::copy(&mut file, zw) { - return Err(ToteError::IOError(e)) + return Err(ToteError::IO(e)) } Ok(()) } @@ -69,7 +69,7 @@ fn write_to_zip(dest: File, targets: Vec, recursive: bool) -> Result<() } } if let Err(e) = zw.finish() { - return Err(ToteError::ArchiverError(e.to_string())); + return Err(ToteError::Archiver(e.to_string())); } Ok(()) } diff --git a/src/cli.rs b/src/cli.rs index 8ddb219..26b2d0f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -70,12 +70,12 @@ pub enum ToteError { NoArgumentsGiven, FileNotFound(PathBuf), FileExists(PathBuf), - IOError(std::io::Error), - ArchiverError(String), + IO(std::io::Error), + Archiver(String), UnsupportedFormat(String), UnknownFormat(String), - UnknownError(String), - SomeError(Box) + Unknown(String), + Fatal(Box) } #[cfg(test)] diff --git a/src/extractor/lha.rs b/src/extractor/lha.rs index b61cdcf..b92393a 100644 --- a/src/extractor/lha.rs +++ b/src/extractor/lha.rs @@ -11,7 +11,7 @@ impl Extractor for LhaExtractor { fn list_archives(&self, archive_file: PathBuf) -> Result> { let mut result = Vec::::new(); let mut reader = match delharc::parse_file(&archive_file) { - Err(e) => return Err(ToteError::IOError(e)), + Err(e) => return Err(ToteError::IO(e)), Ok(h) => h, }; loop { @@ -26,7 +26,7 @@ impl Extractor for LhaExtractor { break; } } - Err(e) => return Err(ToteError::SomeError(Box::new(e))), + Err(e) => return Err(ToteError::Fatal(Box::new(e))), } } Ok(result) @@ -34,7 +34,7 @@ impl Extractor for LhaExtractor { fn perform(&self, archive_file: PathBuf, opts: &ExtractorOpts) -> Result<()> { let mut reader = match delharc::parse_file(&archive_file) { - Err(e) => return Err(ToteError::IOError(e)), + Err(e) => return Err(ToteError::IO(e)), Ok(h) => h, }; loop { @@ -50,14 +50,14 @@ impl Extractor for LhaExtractor { create_dir_all(dest.parent().unwrap()).unwrap(); let mut dest = match File::create(dest) { Ok(f) => f, - Err(e) => return Err(ToteError::IOError(e)), + Err(e) => return Err(ToteError::IO(e)), }; match copy(&mut reader, &mut dest) { Ok(_) => {} - Err(e) => return Err(ToteError::IOError(e)), + Err(e) => return Err(ToteError::IO(e)), } if let Err(e) = reader.crc_check() { - return Err(ToteError::SomeError(Box::new(e))); + return Err(ToteError::Fatal(Box::new(e))); }; } else if !header.is_directory() { opts.v.verbose(format!( @@ -71,7 +71,7 @@ impl Extractor for LhaExtractor { break; } } - Err(e) => return Err(ToteError::SomeError(Box::new(e))), + Err(e) => return Err(ToteError::Fatal(Box::new(e))), } } Ok(()) diff --git a/src/extractor/sevenz.rs b/src/extractor/sevenz.rs index 15de864..30f566d 100644 --- a/src/extractor/sevenz.rs +++ b/src/extractor/sevenz.rs @@ -24,7 +24,7 @@ impl Extractor for SevenZExtractor { } Ok(r) }, - Err(e) => Err(ToteError::SomeError(Box::new(e))), + Err(e) => Err(ToteError::Fatal(Box::new(e))), } } fn perform(&self, archive_file: PathBuf, opts: &ExtractorOpts) -> Result<()> { @@ -32,7 +32,7 @@ impl Extractor for SevenZExtractor { Ok(file) => { file }, - Err(e) => return Err(ToteError::IOError(e)), + Err(e) => return Err(ToteError::IO(e)), }; extract(&mut file, archive_file, opts) } @@ -48,7 +48,7 @@ fn extract(mut file: &File, path: PathBuf, opts: &ExtractorOpts) -> Result<()> { Ok(reader) => { reader }, - Err(e) => return Err(ToteError::SomeError(Box::new(e))), + Err(e) => return Err(ToteError::Fatal(Box::new(e))), }; let folder_count = archive.folders.len(); for findex in 0..folder_count { @@ -57,7 +57,7 @@ fn extract(mut file: &File, path: PathBuf, opts: &ExtractorOpts) -> Result<()> { let dest = opts.destination(&path).join(entry.name.clone()); sevenz_rust::default_entry_extract_fn(entry, reader, &dest) }) { - return Err(ToteError::SomeError(Box::new(e))) + return Err(ToteError::Fatal(Box::new(e))) } } Ok(()) diff --git a/src/extractor/tar.rs b/src/extractor/tar.rs index 7796296..0edaec4 100644 --- a/src/extractor/tar.rs +++ b/src/extractor/tar.rs @@ -112,7 +112,7 @@ where { let file = match File::open(file) { Ok(f) => f, - Err(e) => return Err(ToteError::IOError(e)), + Err(e) => return Err(ToteError::IO(e)), }; let writer = opener(file); Ok(Archive::new(writer)) diff --git a/src/main.rs b/src/main.rs index f796193..4299052 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ fn perform(mut opts: CliOpts) -> Result<()> { Ok(RunMode::Extract) => return perform_extract(opts), Ok(RunMode::List) => return perform_list(opts), Ok(RunMode::Auto) => { - return Err(ToteError::UnknownError( + return Err(ToteError::Unknown( "cannot distinguish archiving and extracting".to_string(), )) } @@ -81,12 +81,12 @@ fn main() -> Result<()> { ToteError::FileExists(p) => { println!("{}: file already exists", p.to_str().unwrap()) } - ToteError::IOError(e) => println!("IO error: {}", e), - ToteError::ArchiverError(s) => println!("Archive error: {}", s), + ToteError::IO(e) => println!("IO error: {}", e), + ToteError::Archiver(s) => println!("Archive error: {}", s), ToteError::UnknownFormat(f) => println!("{}: unknown format", f), ToteError::UnsupportedFormat(f) => println!("{}: unsupported format", f), - ToteError::SomeError(e) => println!("Error: {}", e), - ToteError::UnknownError(s) => println!("Unknown error: {}", s), + ToteError::Fatal(e) => println!("Error: {}", e), + ToteError::Unknown(s) => println!("Unknown error: {}", s), } std::process::exit(1); } diff --git a/templates/README.md b/templates/README.md index 4108b82..bd35ed4 100644 --- a/templates/README.md +++ b/templates/README.md @@ -10,7 +10,7 @@ A tool for extracting/archiving files and directories in multiple formats. -## Description +## :speaking_head: Description There are many archive formats and their tools. The one problem with using each tool is that its interfaces are slightly different. Then, The `totebag` treats the archive files as the same interface. @@ -78,3 +78,8 @@ From this, I chose the name of the tool, totebag, as a tool for packing files an ![logo](site/assets/logo.jpeg) This logo was generated by [Bing Image Creator](https://www.bing.com/images/create/e4b880e381a4e381aee3828ae38293e38194e38292e78987e6898be381a7e6bdb0e38199e794b7e381aee6898be3818ce68f8fe3818be3828ce3819fe38388e383bce38388e38390e38383e382b0e381aee58699e79c9f/1-6614ce41dd1c44aeae12e06dec2e8d68?id=W4JmwP3BnK41FZKKFPisSw%3d%3d&view=detailv2&idpp=genimg&thId=OIG3.H3M7RnPEDRZaxzpZJuii&FORM=GCRIDP&ajaxhist=0&ajaxserp=0). + +## Related Tools + +- [magiclen/xcompress](https://github.com/magiclen/xcompress) + - XCompress is a free file archiver utility on Linux, providing multi-format archiving to and extracting from ZIP, Z, GZIP, BZIP2, LZ, XZ, LZMA, 7ZIP, TAR, RAR and ZSTD.