Giter Site home page Giter Site logo

tzar's Introduction

Tzar: Tar, Zip, Anything Really

Easy compression and extraction for any compression or archival format.

Demo GIF

Usage/Examples

tzar compress large-dir compressed.tar.gz
tzar extract compressed.tar.gz large-dir
tzar list compressed.tar.gz

It's always tzar <command> <source> [<destination>]

Installation

The package is published in PyPi under tzar. You can install it with the following methods

Pipx (recommended)

pipx install tzar

Pip

pip3 install tzar

Dev

git clone [email protected]:DanielVZ96/tzar
cd tzar
poetry install
export TZAR_CONFIG=$PWD/config

Configuration

Configuration is read from the standard directories for each OS (~/.config/tzar/*.toml). You can add any number of toml files to that directory and they will all be read by tzar at runtime.

The configuration file has the following format:

[command or format]
extract = "command extract ${verbose} ${filename} ${directory}" 
compress = "command compress ${verbose} ${directory} ${filename}" 
show = "command list ${verbose} ${filename}" 
extensions = [".ext1",".ext2"]
verbose = "-v" 

[another command or format]
extract = "another x${verbose} ${filename} ${directory}" 
compress = "another c${verbose} ${directory} ${filename}" 
show = "another list ${verbose} ${filename}" 
extensions = [".anoth"]
verbose = "v" 

All commands should have the extract, compress, show, extensions and verbose values defined. They are all self explanatory; they define templates for the commands to run, the extensions for these commands, and how you can ask for a verbose output.

They can all contain the following template variables that will be replaced at runtime:

-verbose: Defines how and where to ask for a verbose output (defined in the verbose = variable definition).

-filename: The name of the compressed file. Corresponds to <source> in the extract and list subcommands, and to <destination> in the compress subcommand

-directory: The target directory. Corresponds to <destination> in the extract and list subcommands, and to <source> in the compress subcommand

Why?

  1. Because I think it's simpler

You may think that this should be doable with aliases, but I tried and I couldn't. Maybe you can use the fuck app or tldr but I still feel it could be simpler to extract files (wtf does xvzf even mean?).

  1. Because I wanted to try the idea of Code as Configuration

Maybe this sounds crazy, but I started this project by exploring the idea of storing the main behaviour of code in configuration files (in this case TOML), in order to ease extensibility, reduce posible errors, and keep things simple. In my dayjob we tried this idea with my colleagues and the result is that changes that previously spawned several files or lines of code, are now reduced into 2 or 3 hard-to-fuck-up yaml lines. If this project gains traction I may write a blog post about this.

TODO

  • [-] Add a ton of new file formats
  • Document code
  • Interactive prompt
  • Tests (Don't judge, I'm coding this in the spare time I have during my lunch breaks.)

Authors

tzar's People

Contributors

danielvz96 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tzar's Issues

file extension not recognized if "file.1.zip"

Had the following interaction:

$ tzar extract thetvdb_6.0.0.0.zip .
No command found for that file extension.
$ mv thetvdb_6.0.0.0.zip thetvdb_6000.zip
$ tzar extract thetvdb_6000.zip .
Running: unzip thetvdb_6000.zip -d .

extract to current dir?

Seems extracting to current dir does not work or is not available?

I want to make a fzf/zle script but it will be much easier if when extracting and no dir is given then a dir is created in the current dir using the filename of the archive being used.

The script I have in mind will list only (all) archives in the current dir, select the archive hit enter and it extracts. simple.

Also how did you get the progress bar?

edit: just realised that was not a progress bar in your gif..but that would be an awesome addition :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.