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 set of 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 - The execution time of spells is reported by default
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 --help
✨ Magic v3.0.0, © 2021 Tatu Arvela
A tool for simplifying repeated command line tasks
Usage:
magic [-s | --show] <spell> [<args>...]
magic [-d | --delete] <spell>
magic -a | --add
magic -e | --edit
magic -l | --list
magic -h | --help
magic -v | --version
Options:
-s --show show spell details
-d --delete delete spell from spellbook
-a --add add spell to spellbook
-e --edit edit spellbook
-l --list list spells in spellbook
-h --help show help
-v --version show version
Editing a spell is currently done with an external editor (Visual Studio Code by default).
Spell arguments
Spells can have an array of arguments, which are populated according to their index. Excessive usage is considered an anti-pattern.
Example:
{
"description": "Test echo spell with arguments '$a0' and '$a1'",
"magicWords": [
"t",
"test"
],
"commands": [
"echo $a0",
"echo $a1"
],
"argumentCount": 2
}
$ magic test cat dog
✨ Test echo spell with arguments 'cat' and 'dog'
cat
dog
✅ 23:46:43 | ⏱ 0:00:00
Advanced usage: Empty arguments
Argument are handled as an array, so arguments can not be empty. As a
work-around they may be substituted with an empty string: ''.
Advanced usage: Spell options
It is possible to provide options (--option) as arguments to spells. This is
not intended usage, but may be useful to some. This requires a little
work-around, as docopt stops the execution if it detects unknown options. You
can provide the options your spell requires by adding a space and
quotes ' --option'.
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,coverage.py - Replace
docoptwithclick
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.0.0.tar.gz.
File metadata
- Download URL: tatuarvela-magic-3.0.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.4 Linux/5.4.0-1046-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
434013283d9cc961036acfcec9c2ec62aa542a785dc0814c46d341553da65913
|
|
| MD5 |
640764fd0b575943930d7bc8059bcc34
|
|
| BLAKE2b-256 |
15f0968ece19e21390744964bf9367a3d71a7b74f825aa5821c4df1bfaf4da20
|
File details
Details for the file tatuarvela_magic-3.0.0-py3-none-any.whl.
File metadata
- Download URL: tatuarvela_magic-3.0.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.9.4 Linux/5.4.0-1046-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca0cb788e3c9987c963a7237c6821043a54289e7194fed85b7e660210b5e68d1
|
|
| MD5 |
07c68bc43c5ac609979dcf1cc6d855de
|
|
| BLAKE2b-256 |
0a6a9060a9699883006a34fd1f1abcb52c785b1d1808bbdf7faa2a3688ba532f
|