A tool for simplifying repeated command line tasks
Project description
Magic
Magic is a tool for wrapping repeated command line tasks into simple scripts.
- A sequence of console commands is saved as a spell
- Spells are written into the spellbook file (
~/.spellbook.json) - Each spell can be called with one or several magic words
e.g.magic build-appandmagic ba - Spells can have arguments passed to them
e.g.magic say abra kadabra - Magic can report the execution time of spells, which may be useful for longer operations
Installation
Magic is designed for macOS and common Linux distributions using Bash or Zsh. Windows is not supported.
Magic requires Python 3.9, and can be installed using pip:
python3 -m pip install tatuarvela-magic
See also: Development installation
Usage
$ magic
✨ Magic v3.1.0 © 2021 Tatu Arvela
A tool for simplifying repeated command line tasks
Usage: magic [OPTIONS] COMMAND [ARGS]...
Options:
-h, --help Show this message and exit.
Commands:
add Add spell to spellbook
e Example echo spell with arguments '$a0' and '$a1'
edit Open spellbook in editor
example Example echo spell with arguments '$a0' and '$a1'
Editing the spellbook is currently done with an external editor (Visual Studio Code by default).
Spell options
$ magic example --help
Usage: magic example [OPTIONS]
Example echo spell with arguments '$a0' and '$a1'
Options:
-d, --delete Delete this spell.
-s, --show Show details of this spell.
-h, --help Show this message and exit.
Other options are interpreted as arguments for spells.
Spell arguments
Spells can have an array of arguments, which are populated according to their index. Excessive usage is considered to be an anti-pattern, it is recommended to create separate spells instead.
Example:
{
"description": "Example echo spell with arguments '$a0' and '$a1'",
"magicWords": [
"e",
"example"
],
"commands": [
"echo $a0",
"echo $a1"
],
"argumentCount": 2
}
$ magic example cat dog
✨ Example echo spell with arguments 'cat' and 'dog'
cat
dog
✅ 23:46:43 | ⏱ 0:00:00
Advanced usage: Empty arguments
Argument are handled as an ordered array. If necessary, it is possible to make an argument an empty string: ''.
Development
Development installation
- Supported operating systems: macOS (untested on Linux)
- Requirements: Python 3, Poetry
-
Clone the Git repository somewhere and navigate to it on the command line
git clone https://github.com/TatuArvela/Magic.git cd Magic
-
Install
magicand its dependencies to a virtual envpoetry install -
Verify that
magicworkspoetry run magic
-
Register
magicto yourPATHpython -m write_path
When developing the tool, you should use the magic module directly
with python -m magic.
After successful changes, you need to run poetry install again to update the
version in your PATH.
Code quality tools
Magic uses isort, black and flake8 as its code quality tools. They are
executed automatically with pre-commit and can also be executed with the
included lint script:
python -m lint
TODO
For 3.X.X releases
- Add
pytest,snapshottest,coverage.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tatuarvela-magic-3.1.0.tar.gz.
File metadata
- Download URL: tatuarvela-magic-3.1.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.9.5 Linux/5.4.0-1047-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59042312c080cebf6cb5ba901a9102c4d4c293492b582f238d2f986fd49d37bd
|
|
| MD5 |
1ac32b0fa6a95e598a4d79f1c44a7afd
|
|
| BLAKE2b-256 |
316c04a141e0dd071da050caf8716dcfca47327ad9bd9bb069e640ad87697e0d
|
File details
Details for the file tatuarvela_magic-3.1.0-py3-none-any.whl.
File metadata
- Download URL: tatuarvela_magic-3.1.0-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.9.5 Linux/5.4.0-1047-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d4a61ad9f5e97a928402c7309e2c466a5e30baa16c632fd9760c98382246a3d
|
|
| MD5 |
04c3eb3b601c4766c2d519f0ff401f79
|
|
| BLAKE2b-256 |
4a4037f000b15910e9ddd84bd55269647ab3dd6464a21357fb710679e360e062
|