Skip to content

Commit

Permalink
Merge branch 'vrmiguel:master' into test/oof-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
demfabris committed May 31, 2021
2 parents 7aca9bd + f952392 commit 42fee73
Show file tree
Hide file tree
Showing 18 changed files with 268 additions and 250 deletions.
11 changes: 1 addition & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ouch"
version = "0.1.4"
version = "0.1.5"
authors = ["Vinícius Rodrigues Miguel <vrmiguel99@gmail.com>", "João M. Bezerra <marcospb19@hotmail.com>"]
edition = "2018"
readme = "README.md"
Expand All @@ -21,9 +21,6 @@ tar = "0.4.33"
xz2 = "0.1.6"
zip = "0.5.11"

# Dependency from workspace
oof = { path = "./oof" }

[dev-dependencies]
tempdir = "0.3.7"
rand = { version = "0.8.3", default-features = false, features = ["small_rng", "std"] }
Expand All @@ -32,9 +29,3 @@ rand = { version = "0.8.3", default-features = false, features = ["small_rng", "
lto = true
codegen-units = 1
opt-level = 3

[workspace]
members = [
".",
"oof",
]
101 changes: 53 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,105 +2,114 @@

<!-- ![ouch_image](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR5ilNDTFZZ-Vy_ctm2YyAe8Yk0UT7lB2hIhg&usqp=CAU) -->

`ouch` loosely stands for Obvious Unified Compression files Helper and aims to be an easy and intuitive way of compressing and decompressing files on the command-line.
`ouch` loosely stands for Obvious Unified Compression files Helper.

It is an easy and painless way of compressing and decompressing files in the terminal.

Works in `Linux`, `Mac OS` and `Windows`.

<!-- - [Listing files](#Listing-the-elements-of-an-archive) -->

- [Usage](#Usage)
- [Decompressing files](#Decompressing-files)
- [Compressing files/directories](#Compressing-files-and-directories)
- [Listing files](#Listing-the-elements-of-an-archive)
- [Supported Formats](#Supported-formats)
- [Installation](#Installation)
- [Supported Formats](#Supported-formats)
- [Supported operating systems](#Supported-operating-systems)

## Usage

### Decompressing files

To decompress any number of files, just supply them to `ouch`.
### Decompressing

Use the `-o, --output` flag to redirect the output of decompressions to a folder.
Run `ouch` and pass compressed files as arguments.

```sh
# Decompress `a.zip`
ouch a.zip

# Decompress multiple files
ouch a.zip b.tar.gz
```

Use the `-o/--output` flag to redirect the output of decompressions to a folder.

```sh
# Decompress multiple files but inside new_folder
ouch a.zip b.tar.gz c.tar.bz2 -o new_folder
```

### Compressing files and directories

The `compress` subcommand is able to compress files and folders. The **last** argument will be the **output file**.
### Compressing

You can also use the `c` alias for this subcommand.
Use the `compress` subcommand.

The compression format employed will be defined according to the output file's extension.
Accepts files and folders, and the **last** argument shall be the **output file**.

```sh
# Compress four files into `archive.zip`
ouch compress a b c d archive.zip
ouch compress 1 2 3 4 archive.zip
```

# Compress three files into a `.tar.bz2` archive
ouch compress a.mp4 b.jpg c.png files.tar.bz2
The supplied **output file** shall have a supported compression format, [see the list](#Supported-formats).

You can also use the `c` alias for this subcommand.

```sh
# Compress a folder and a file into `videos.tar.xz`
ouch compress Videos/ funny_meme.mp4 videos.tar.xz
ouch c Videos/ funny_meme.mp4 videos.tar.xz

# Compress three files into a `.tar.bz2` archive
ouch c a.mp4 b.jpg c.png files.tar.bz2

# Compress two folders into a lzma file
ouch c src/ target/ build.tar.lz
```

### Listing the elements of an archive
<!-- ### Listing the elements of an archive
* **Upcoming feature**
```
# Shows the files and folders contained in videos.tar.xz
ouch list videos.tar.xz
```

## Supported formats


| | .tar | .zip | .tar.\*¹ | .zip.\*² | .bz, .bz2 | .gz | .xz, .lz, .lzma | .7z |
|:-------------:|:----:|:----:|:--------:|:--------:|:---------:| --- |:---------------:| --- |
| Decompression |||||||||
| Compression |||||||||

```
Note: .tar.*¹: .tar.gz, .tar.bz, .tar.bz2, .tar.xz, .tar.lz, .tar.lzma, .tar.zip
.zip.*²: .zip.gz, .zip.bz, .zip.bz2, .zip.xz, .zip.lz, .zip.lzma, .zip.zip
```

``` -->

## Installation

### Getting a pre-compiled binary
### Installing a binary

This script downloads the latest binary and copies it to `/usr/bin`.
```sh
curl -s https://raw.githubusercontent.com/vrmiguel/ouch/master/install.sh | sh
```

### Building
### Compiling
Install [Rust](rust-lang.org) and [Cargo](https://doc.rust-lang.org/cargo/) via [rustup.rs](https://rustup.rs/).

A recent [Rust](rust-lang.org) toolchain is needed to build `ouch`. You can install it following the instructions at [rustup.rs](https://rustup.rs/).
From latest official release:
```sh
cargo install ouch
```

Once [Cargo](https://doc.rust-lang.org/cargo/) is installed, run:
From repository source code:

```sh
cargo install ouch
# or
git clone https://github.com/vrmiguel/ouch
cargo install --path ouch
# or
git clone https://github.com/vrmiguel/ouch
cd ouch && cargo run --release
cargo build
```

## Supported formats

| | .tar | .zip | .tar.\*¹ | .zip.\*² | .bz, .bz2 | .gz | .xz, .lz, .lzma | .7z |
|:-------------:|:----:|:----:|:--------:|:--------:|:---------:| --- |:---------------:| --- |
| Decompression |||||||||
| Compression |||||||||

```
Note: .tar.*¹: .tar.gz, .tar.bz, .tar.bz2, .tar.xz, .tar.lz, .tar.lzma, .tar.zip
.zip.*²: .zip.gz, .zip.bz, .zip.bz2, .zip.xz, .zip.lz, .zip.lzma, .zip.zip
```

## Supported operating systems
<!-- ## Supported operating systems
`ouch` runs on Linux, macOS and Windows 10. Binaries are available on our [Releases](https://github.com/vrmiguel/ouch/releases) page.
Expand All @@ -111,8 +120,4 @@ Binaries are also available at the end of each (successful) [GitHub Actions](htt
* Windows 10
* Linux ARMv7 dynamically linked (glibc)
One must be logged into GitHub to access build artifacts.

## Limitations

`ouch` does encoding and decoding in-memory, so decompressing very large files with it is not advisable.
One must be logged into GitHub to access build artifacts. -->
134 changes: 69 additions & 65 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,78 +1,82 @@
#! /usr/bin/sh

# Needs to be updated each version bump
VERSION="0.1.4"
VERSION="0.1.5"

DOWNLOAD_LOCATION="/tmp/ouch"
INSTALLATION_LOCATION="/usr/bin/ouch"
REPO_URL="https://github.com/vrmiguel/ouch"

# Panicks script if anything fails
set -e

abort() {
echo "error occurred, aborting." ; exit 1
}

# Panicks script if anything fails
set -e
install() {
echo "Ouch v$VERSION."

printf "Detected system: "
# System detection from https://stackoverflow.com/a/27776822/9982477
# Go there to see a full table of what `uname -s` might output
case "$(uname -s)" in
Linux)
echo "Linux."
system_suffix="-ubuntu-18.04-glibc"
;;

Darwin)
echo "Mac OS X."
system_suffix="-macOS"
;;

CYGWIN*|MINGW32*|MSYS*|MINGW*)
echo "Windows."
system_suffix=".exe"
;;

*)
echo "ERROR."
echo "This script only works for installing on Linux, Mac OS and Windows."
echo "We found '$(uname -s)' instead."
echo ""
echo "To install 'ouch' you can opt for other installation method"
echo "listed at $REPO_URL"
echo ""
echo "If you think this is an error, please open an issue"
exit 1
;;
esac

binary_url="https://github.com/vrmiguel/ouch/releases/download/${VERSION}/ouch${system_suffix}"

echo ""

if [ -f "$DOWNLOAD_LOCATION" ]; then
echo "Reusing downloaded binary at '$DOWNLOAD_LOCATION'."
else
echo "Downloading binary to '$DOWNLOAD_LOCATION' with curl."
echo "From $binary_url"
curl -fSL $binary_url -o $DOWNLOAD_LOCATION
fi

echo ""

if [ "$USER" = "root" ]; then
echo "Detected root user, trying to copy $DOWNLOAD_LOCATION to $INSTALLATION_LOCATION."
cp $DOWNLOAD_LOCATION $INSTALLATION_LOCATION || abort
else
echo "Asking for \"sudo\" permissions to finish installation."
echo "Permission is needed to copy '$DOWNLOAD_LOCATION' to '$INSTALLATION_LOCATION'"

sudo cp $DOWNLOAD_LOCATION $INSTALLATION_LOCATION || abort
fi

echo ""

echo "Successfully installed!"
echo "See $REPO_URL for usage instructions."
}

echo "Ouch v$VERSION."

printf "Detected system: "
# System detection from https://stackoverflow.com/a/27776822/9982477
# Go there to see a full table of what `uname -s` might output
case "$(uname -s)" in
Darwin)
system_suffix="-macOS"
echo "Mac OS X."
;;

Linux)
echo "Linux."
system_suffix="-ubuntu-18.04-glibc"
;;

CYGWIN*|MINGW32*|MSYS*|MINGW*)
echo "Windows."
system_suffix=".exe"
;;

*)
echo "ERROR."
echo "This script only works for installing on Linux, Mac OS and Windows."
echo "We found '$(uname -s)' instead."
echo ""
echo "To install 'ouch' you can opt for other installation method"
echo "listed at $REPO_URL"
echo ""
echo "If you think this is an error, please open an issue"
exit 1
;;
esac

binary_url="https://github.com/vrmiguel/ouch/releases/download/${VERSION}/ouch${system_suffix}"

echo ""

if [ -f "$DOWNLOAD_LOCATION" ]; then
echo "Reusing downloaded binary at '$DOWNLOAD_LOCATION'."
else
echo "Downloading binary to '$DOWNLOAD_LOCATION' with curl."
echo "From $binary_url"
curl -fSL $binary_url -o $DOWNLOAD_LOCATION
fi

echo ""

if [ "$USER" = "root" ]; then
echo "Detected root user, trying to copy $DOWNLOAD_LOCATION to $INSTALLATION_LOCATION."
cp $DOWNLOAD_LOCATION $INSTALLATION_LOCATION || abort
else
echo "Asking for \"sudo\" permissions to finish installation."
echo "Permission is needed to copy '$DOWNLOAD_LOCATION' to '$INSTALLATION_LOCATION'"

sudo cp $DOWNLOAD_LOCATION $INSTALLATION_LOCATION || abort
fi

echo ""

echo "Successfully installed!"
echo "See $REPO_URL for usage instructions."
install
9 changes: 0 additions & 9 deletions oof/Cargo.toml

This file was deleted.

Loading

0 comments on commit 42fee73

Please sign in to comment.