A lightweight script management system for everyday tasks.
Mango utilizes the file system to provide fast and intuitive access to well-organized scripts. It is extremely suitable for managing scripts on personal computers, and is both robust and versatile.
Mango primarily targets Linux, though it should be easily adapted to suit other OS systems. Pull requests and feature requests are welcome regarding cross-platform support.
This project requires Python, and is tested on Python 3.12, though it should work on Python 3.6 and above. Make sure you have a compatible version of Python installed on your system. If not, you can run:
sudo apt install python3.12You can use the provided installer script to set up Mango automatically. Run the following command in your terminal:
curl -LsSf https://raw.githubusercontent.com/Mango-CLI/Mango/main/install.sh | bashMango itself is a single Python script in src/, so you only need to download it and put it somewhere in your system PATH.
To reconstruct the home mango, you need to manually scaffold the builtins.mango submodule.
- First, create
~/.mango/if it doesn't exist and then create the.submodulesfolder:
mkdir -p ~/.mango/.submodules- Clone the builtins submodule into the
.submodulesfolder:
git clone https://github.com/Mango-CLI/builtins.mango.git ~/.mango/.submodules/builtins- Finally, create or edit the
~/.mango/.instructionsfile to export the builtins submodule. Type in:
# Builtin mango scripts
[builtins] *
This will make all builtin mango commands available without needing to prepend submodule path.
New to Mango? Follow these steps to get started quickly:
-
Initialize a new Mango repository in your project directory:
cd ~/my-project mango @init
-
Create your first script with a command binding:
mango @add hello -b greet
-
Edit the script to add your functionality:
# The script will open in your default editor # Add this content: echo "Hello, Mango!"
-
Run your script using the command binding:
mango greet
-
List all available commands in your repository:
mango @list
A mango repository is any directory containing a .mango folder. The .mango folder contains an .instructions file that defines the bindings between commands and scripts.
- A script is a file managed by mango which can be executed
- A binding is a tag attached to a script, used by the user to invoke it
- A command is an invocation of an item by its binding
- Normal commands only search within the active mango repo (closest
.mangofolder) - Host commands (prefixed with
@) search up the filesystem, across multiple mango repos, until they find a matching binding
For detailed information about any command, use the help system:
mango @help [command]mango @help- Display help for mango commandsmango @which- Show which script a command is bound tomango @self update- Update the mango executablemango @self uninstall- Uninstall the mango executable
mango @init- Create a new mango repositorymango @deinit- Remove the mango repository metadatamango @list- Show scripts and bindings in a repository
mango @add- Create or reopen a scriptmango @edit- Open an existing scriptmango @remove- Delete scripts or drop their bindings
mango @bind- Attach commands to a scriptmango @unbind- Detach commands from a script
Submodules are mango repositories nested inside .mango/.submodules/. They are designed to be externally maintained and facilitate easier version management.
To reference commands from a submodule, use the syntax module-path:command-name:
mango module-1:aTo create your own submodule, make a project folder, cd inside and run:
mango init --template submoduleThe template will automatically setup the project as a git repo.
A template is a mango submodule designed to replace the outer .mango folder with its own .mango folder. Templates are useful for creating project scaffolding.
To build a template, cd into the project folder and run:
mango @init --template templateYou should have noticed that you can already use a selection of mango templates (like python, submodule and template). These are stored in the builtins submodule.
When you finish creating a mango submodule or template, you can either publish it to a remote git repository, or store it locally. Run mango @{template,submodule} register to register into your local mango registry (~/.mango/.*.registry).
You will then be able to use them like builtin templates and submodules, using their name.
mango @submodule list
mango @template list
You can run these commands to view your registered submodules and templates.
Hooks are scripts that are executed when called by another script. They follow name conventions. All hooks in Mango are CONVENTIONAL, which means that they are NOT part of any syntax. They work because the mango builtin scripts look for them and execute them if they exist.
Default hooks:
.on-add: Called after@addis triggered.on-install: Called after a submodule (or template) is installed.
You are free to customize and create your own hooks for your scripts as you see fit.
When mango invokes a script, it sets the following environment variables:
MANGO: set to indicate that the script is being run by mangoMANGO_REPO_PATH: path to the directory containing .mangoMANGO_USER_PATH: path to the user's present working directory when invoking mangoMANGO_SCRIPT_PATH: full path to the script being invokedMANGO_SCRIPT_NAME: name of the script being invoked
-
Command not found: Ensure that mango is in your system PATH and that you have a
.mangofolder in your current directory or a parent directory. -
Script not executable: Mango automatically makes scripts executable, but if you're having issues, check the script permissions with
ls -la .mango/. -
Editor not opening: Make sure you have the
EDITORenvironment variable set to your preferred editor.
The logo was made by Freepik from Flaticon. For more information, see the license in img/license-flaticon.
