Skip to content
/ Zeven Public

A python tool designed to format or compact code in large or small projects quickly

License

Notifications You must be signed in to change notification settings

Syyysco/Zeven

Repository files navigation

Zeven - A powerful code booster

Build Status license Last Commit Available on all Platforms Tool Type
A Zeven lifes for advanced developers.

Key features and overview
Installation for Windows
Installation for Linux and MacOS
How to use
Using setting mode
Setting mode: Configuration
Setting mode: Customization
Available languajes
Parameters cheatsheet
Possible errors
Project goals and future ideas
License



Sysco - A mad hardcoder




Key Features and Overview

Zeven is a command-line tool designed to efficiently format and/or compact code, making it more readable and maintainable, or alternatively reducing its size and processing time.

litle-overview

Tip

Designed as an open-source project, focused on optimization and accessibility for developers and teams.

100% Built with Python

  • Compatible with Windows, Linux, and macOS
  • Supports multiple specific formats
  • Allows custom configurations
  • Extremely fast for large projects
  • Parallel execution with threads to maximize performance
  • Includes an interactive configuration mode for ease of use
  • Particularly useful for web projects

Install

Important

Do not clone the repository or run the tool as root or administrator user, it will fail when running.

  • As a first step it is important to emphasize that you need to have git installed, you can install it from here. After that you simply have to clone this repository:
    git clone https://github.com/Syyysco/Zeven.git
  • If you have already installed the tool and want to remove everything, simply go to the tool folder (where you cloned or moved it) and run the following command and then delete the Zeven folder:
    pip3 uninstall -r requirements.txt
    

In the case of Windows, change requirements.txt to win-requirements.txt



Build Status Build Status Build Status Build Status Build Status


Installation for Windows

  1. You need to have python3 installed, if you don't have it installed you can do it from the Microsoft Store or by running the following command on your terminal (CMD or PowerShell):

    winget install -e --id Python.Python.3.9 --scope machine
  2. If you installed a version later than or equal to python3.4, pip will already be installed by default (it will be necessary for this step), if you have another version you can install pip very easily with this guide (two steps). In case pip is installed (check it with pip --version), You can continue by accessing the Zeven directory and installing the requirements for windows with this command:

    pip install -r win-requirements.txt
  3. And that's it! Now if you want to be able to run it without having to indicate the absolute path and/or put python3 in each command you can add it to the system PATH or create an alias. Remember to report any bugs, or suggest any changes or additions in the issues section.


Installation for Linux and MacOS

  1. You need to have python3 installed, if you don't have it installed you can look at this guide to have a more complete view here or by running the following command on your terminal:

    sudo apt update
    sudo apt install python3
  2. If you installed a version later than or equal to python3.4, pip will already be installed by default (it will be necessary for this step), if you have another version you can install pip very easily with this guide (one step). In case pip is installed (check it with pip3 --version), you can continue by accessing the Zeven directory and installing the requirements with this command:

    pip3 install -r requirements.txt
  3. And that's it! Now if you want to be able to run it without having to indicate the absolute path and/or put python3 in each command you can add it to the system PATH or create an alias. Remember to report any bugs, or suggest any changes or additions in the issues section.


How To Use

Note

  • If you have not added Zeven to the PATH, the execution will be as follows: python3 zeven.py <options> <args>
  • In this case, the use cases will be represented assuming that it was added to the PATH: zeven <options> <args>

With Folders

  • Compact all files contained in a folder (for entire projects) and save it as a new project:
    zeven -i project -o proyect2
  • Compact all files contained in a folder (for entire projects) and overwrite it:
    zeven -i project -D
  • Format only the "html" and "javascript" files of a project (folder) and overwrite it:
    zeven -i project -dD -f "html,js"
  • Format all files in a folder with a 4-space indentation and overwrite it:
    zeven -i project -dD -I 4
  • Compact only the "html" files in a project without modifying the content of the <style> and <script> tags:
    zeven -i project -o proyect2 -f "html" -s

With Files

  • Compact a file into a single line and overwrite it:
    zeven -i main.js
  • Format a file and save it as a new file:
    zeven -i index.php -o path/to/new/index.php
  • Formatting a file correctly and print it without saving the result:
    zeven -i index.html -dp
  • Display the result of compacting a file with a non-autodetected format and save it in the same file:
    zeven -i file -o file -p -f css
  • Format with a 8-space indentation and overwrite the file:
    zeven -i styles.css -I 8 
  • Format a file without modifying the content of the <style> and <script> tags and save it on a new file:
    zeven -i index.php -s -o new_index.php

Settings mode

  • Launches interactive configuration mode:
    zeven -C

Search for help on panels quickly

  • Search for keywords in the compact help panel:
    zeven -h output
    zeven -h -I
    zeven -h backups
  • Search for keywords in the full help panel:
    zeven -H --format
    zeven -H configuration
    zeven -H -s

Update Zeven

  • Update the app if there is a new version (connection required):
    zeven -U

Backups

  • Delete all stored backups:
    zeven --flush-backups

Reconfigure

  • Reset Zeven settings to default:
    zeven --reconfigure

Using Setting Mode

In configuration mode you can change certain relevant settings regarding operation, information display and other aspects.

  1. You will find two panels at the top, configuration on the left and customization on the right.

  2. You can switch panels with the left and right arrow keys, and switch between their options with the up and down arrow keys or the mouse wheel.

  3. Below is the status panel and by pressing H you can show/hide the help panel.

  4. To change the value of any setting press ENTER:

  • If the setting is ON/OFF it will simply be changed.
  • If the setting is a number or a text field you will enter editing mode.

Note

To edit values:

  • For numeric values ​​you can increase or decrease the value with up-down arrow keys.
  • For text input just type (the help panel will open which is where the typed text is displayed).
  • Then simply press ENTER to save the changes or ESC to cancel.
  1. Press R on any selected option to restore it to its default value.

  2. If you press Q you will exit configuration mode and save the changes.

  3. On the other hand, if you press ESC you will exit without saving.


Setting Mode: Configuration

Skip Invalid Parameters

Some arguments may sometimes be introduced unnecessarily, added incorrectly (perhaps unintentionally), or be incompatible in certain cases. This setting allows certain errors related to the aforementioned issues to be ignored, enabling the execution to continue without triggering errors.

Directory Overwrite Lock

By default, directories are not overwritten unless the -D parameter is used to execute in directory mode or the same input and output paths are specified with the -o parameter (e.g., sevven -i folder1 -o folder1). Disabling directory overwrite protection will cause directories to be overwritten simply by providing an input (e.g., sevven -i folder1).

Debug Mode

Debug mode provides more detailed information during execution and upon completion. This is especially useful for developers who want to contribute to the tool, as it makes it much easier to understand its behavior with greater precision.

Beta Languages

Some languages are not enabled by default because their behavior is not yet fully controlled and they are still under development. Enabling this setting will treat these experimental languages the same as others. It’s important to verify the results after making changes.

Verbosity Level

You can adjust the level of information displayed on the screen from multiple levels:
0: Nothing will be displayed, not even errors.
1: Only errors will be displayed.
2: Displays the current progress and the size difference upon completion.
3: Shows updated files during execution.
4: Shows files that were not updated during execution and warnings.
5: Highlights errors and warnings for easier identification in large projects.

Create Project Backups

When enabled, a backup will be created every time the tool is run on a project (file or directory), allowing you to recover data in case of loss or other issues. The backup directory is located at default path, but you can change this.

Maximum Backups

You can set the maximum number of backups to be stored in the designated path before older backups start being deleted. However, you can manually delete all backups using the --flush-backups parameter.

Backup Folder

By default, backups are stored in the default path, but you can change this to a custom folder on your device. If the folder becomes inaccessible at any point, the default path will be restored automatically.

Use Threads

This setting only affects directories.
Sometimes some projects are extremely large and contain a lot of files, in which case it is advisable to enable the use of threads so that the execution takes as little time as possible. On small projects it is not necessary to use threads, since the difference will be milliseconds.

Maximum Threads

You can specify the number of threads to use.
This defines a maximum number of threads that can be in parallel at the same time and will never be exceeded. Consider using the most appropriate number for your computer, considering the resources available.


Setting Mode: Customization

Shows Progress Bar

Displays the current progress along with an animated bar at the bottom of the screen, indicating that the tool is running.

Color Highlighting

Displays all output in a colorized format, including within the configuration menu, help panels, updated files, progress bar, errors, and warnings. This is useful for making the output much easier to read.

Sounds

Enables or disables all application sounds, including for the configuration menu and notifications. If this setting is turned off, all notification-related settings will also be disabled.

Completion Notification

When tasks are completed, a sound will play by default to notify you that the process has finished. This is useful for large projects that might take longer than expected.

Time Until Notification

For very small projects or single files, processing time is usually brief, making notifications unnecessary. Set the minimum execution time (in seconds) after which you wish to be notified. Processes shorter than this time will not trigger notifications.

Error Notification

Customize the notification sound for errors.

Success Notification

Customize the notification sound for successful processes.

Help on Parameter Errors

Decide whether to display the help panel alongside the current error when incorrect parameter or argument usage is detected. If disabled, only the error itself will be displayed.


Available Languages

So far, this is the list of file types implemented in the application:

Fully Functional In Development (Beta)
HTML Python
CSS TypeScript
JavaScript SQL
Json
PHP

Parameters CheatSheet

Parameter Description
-h, --help Show compact help message and exit
-H, --fullhelp Show the full help panel
-U, --update Update the app if possible
--version Print the current version of zeven
--reconfigure Restore default settings
--flush-backups Remove all stored backups
-C Launch configuration mode
-i, --input Specify an input to format
-o --output Specify an output (overwrite directories)
-f, --format Specify format of files (not be necessary)
-I, --indent Define the indentation size (default: 4)
-t, --threads Indicates the number of threads to use
-p, --print Print the compressed/formatted code
-D Specify a directory mode to format all files
-d Turn to decompress method
-s The <style> and <script> tags will not be affected

INDIVIDUAL COMBINABLE COMPACTABLE
-h, --help -i, --input -p, --print
-H, --fullhelp -o --output -D
-U, --update -f, --format -d
--version -I, --indent -s
--reconfigure -t, --threads
--flush-backups
-C

Possible Errors

Error installing or uninstalling packages with pip or pip3

Have you experienced an error like this?

error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

    See /usr/share/doc/python3.11/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
  • Simply add the --break-system-packages parameter to the end of the command, for example:
    pip3 install -r requirements.txt --break-system-packages

    The latest python3 updates give this error if you are not in a virtual environment



Error installing requirements on Bash/Zsh

Are you getting the following error?

  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-57api9bk/grapheme_9a33c91994e045e0bc521c8e6dd44e02/setup.py", line 2,>          from setuptools import setup, find_packages
      ImportError: cannot import name 'setup' from 'setuptools' (unknown location)
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

This problem is simply because the setuptools library on your system is not updated, you just need to update it with the following command:

pip3 install --upgrade pip setuptools


Error installing requirements on Windows

ERROR: Could not find a version that satisfies the requirement windows-curses==2.4.0 (from versions: none)
ERROR: No matching distribution found for windows-curses==2.4.0

If you are on Windows and as a last resort when installing the requirements you got this error, try manually installing the compatible version as follows:

pip3 install windows-curses

Project Goals and Future Ideas

The idea for the future of this project is mainly that it ends up being a tool contained within a pentesting suite.

  • Why?

It is actually very easy to borrow the source code in production but normally developers compact it to save space and it ends up being unintelligible, in that case Zeven is a good tool for analysis.

When it comes to compacting code it is also useful for the same reason, making readability difficult. The idea is to soon implement a group of modules to obfuscate the code and be able to bypass certain filters, detection systems in code injections, etc.

In conclusion this is the beginning of a great cybersecurity project!


License

zeven is made available under the terms of either the GNU General Public License (GPL).
You are free to use, modify, and distribute this project, provided you comply with the terms of the license.
The full license details are available in the LICENSE file.

For more information about the GPL License, visit the official GNU website.





Sysco - A mad hardcoder