Skip to content

Commit

Permalink
Merge pull request #29 from tamada/release/v0.5.0
Browse files Browse the repository at this point in the history
Release/v0.5.0
  • Loading branch information
tamada authored Jun 25, 2024
2 parents 36a8a7e + aecae6e commit 24f3f1b
Show file tree
Hide file tree
Showing 34 changed files with 233 additions and 44 deletions.
1 change: 0 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/update-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file added .gitmodules
Empty file.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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/}

Expand All @@ -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

Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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]...

Expand All @@ -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
Expand All @@ -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`
Expand All @@ -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.
29 changes: 29 additions & 0 deletions dockers/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]

22 changes: 22 additions & 0 deletions dockers/distroless/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
File renamed without changes.
Binary file added docs/assets/authors/harry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
5 changes: 5 additions & 0 deletions docs/config/_default/hugo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
baseURL = "https://tamada.github.io/totebag/"
defaultContentLanguage = "en"
languageCode = "en"
enableEmoji = true
math = true
Empty file.
2 changes: 2 additions & 0 deletions docs/config/_default/module.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[[imports]]
path = "github.com/maolonglong/hugo-simple"
Empty file.
25 changes: 25 additions & 0 deletions docs/content/_index.md
Original file line number Diff line number Diff line change
@@ -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)

26 changes: 26 additions & 0 deletions docs/content/about.md
Original file line number Diff line number Diff line change
@@ -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.
26 changes: 26 additions & 0 deletions docs/content/install.md
Original file line number Diff line number Diff line change
@@ -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`
37 changes: 37 additions & 0 deletions docs/content/usage.md
Original file line number Diff line number Diff line change
@@ -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> 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
- Tar+Zstd
- Zip
- 7z
- Lha, Lzh (extraction only)
- Rar (extraction only)
5 changes: 5 additions & 0 deletions docs/go.mod
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions docs/go.sum
Original file line number Diff line number Diff line change
@@ -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=
4 changes: 2 additions & 2 deletions src/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/archiver/sevenz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn process_file(szw: &mut SevenZWriter<File>, 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(())
}
Expand Down Expand Up @@ -61,15 +61,15 @@ 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(())
}

fn write_sevenz(dest: File, targets: Vec<PathBuf>, 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())),
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/archiver/tar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ fn write_tar_impl<W: Write>(file: W, targets: Vec<PathBuf>, 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<W: Write>(builder: &mut Builder<W>, 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 {
Expand All @@ -114,7 +114,7 @@ fn process_dir<W: Write>(builder: &mut Builder<W>, target: PathBuf, recursive: b

fn process_file<W: Write>(builder: &mut Builder<W>, 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(())
}
Expand Down
6 changes: 3 additions & 3 deletions src/archiver/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ fn process_file<W:Write+Seek> (zw: &mut ZipWriter<W>, 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(())
}
Expand All @@ -69,7 +69,7 @@ fn write_to_zip(dest: File, targets: Vec<PathBuf>, recursive: bool) -> Result<()
}
}
if let Err(e) = zw.finish() {
return Err(ToteError::ArchiverError(e.to_string()));
return Err(ToteError::Archiver(e.to_string()));
}
Ok(())
}
Expand Down
8 changes: 4 additions & 4 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn std::error::Error>)
Unknown(String),
Fatal(Box<dyn std::error::Error>)
}

#[cfg(test)]
Expand Down
Loading

0 comments on commit 24f3f1b

Please sign in to comment.