Magic
Magic is a tool for turning repeated command line tasks and long, hard to remember commands into quickly callable simple commands, spells.
Spells provide a simple and managed alternative to manually created aliases or scripts.
🏃 Quick tour
- To add spells, run the built-in wizard
magic add - Spells are written into the spellbook file (
~/.spellbook.json) - Each spell is available as a command under
magic, which can be listed withmagic --help - A spell can have one or several command names, which are called magic
words
e.g.magic build-appandmagic ba - Spells can have arguments passed to them
e.g.magic say abra kadabra
💻 Installation
Magic is designed for macOS and common Linux distributions using Bash or Zsh. Magic also works on Windows Subsystem for Linux.
Magic requires Python 3.7 or above, and can be installed using pip:
python3 -m pip install tatuarvela-magic
🪄 Usage
$ magic
✨ Magic © 2022 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).
📚 Documentation
Spell options
Spell options can be listed with the -h or --help option.
$ 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.
-d or --delete option can be used to delete a spell.
-s or --show option can be used to show the details of a spell.
Other options are interpreted as arguments for spells.
Spell arguments
Spells can have an array of arguments, which are populated according to their index, starting from 0.
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
✅ 12:30:43 | ⏱ 0:00:00
The arguments can be used in the spell description and commands.
The description arguments are replaced when displaying the spell message.
argumentCount property is automatically inferred from the description and
commands.
Excessive usage of arguments is considered to be an anti-pattern, it is recommended to create separate spells instead.
Advanced usage: Empty arguments
Argument are handled as an ordered array. If necessary, it is possible to make
an argument an empty string: ''.
Messages
Message
Magic can print the description of a spell, filled with the provided arguments
✨ Example echo spell with arguments 'cat' and 'dog'
showMessage property defaults to true.
Success message
Magic can show a success message which reports the starting time and duration of a spell. This may be useful for longer operations.
✅ 23:46:43 | ⏱ 0:00:00
showSuccessMessage property defaults to true.
⚙️ Development
Development instructions and notes can be found in DEVELOPMENT.md
Metadata
Release files for tatuarvela-magic 3.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tatuarvela-magic-3.1.3.tar.gz | 11.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tatuarvela_magic-3.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.3 kB
Release files / tatuarvela-magic-3.1.3.tar.gz
| Download URL | tatuarvela-magic-3.1.3.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91ce00c73d88b48f7951f6843f16b459519698d49dd743451a9c995feaa22f61
|
|
BLAKE2b-256 checksum How to use checksums |
01b0ff6855ab34ba53d4ccb593ad96ee08a65c5141949f52724d2ee9f2dccf30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.9.10 Linux/5.11.0-1028-azure
|
Release files / tatuarvela_magic-3.1.3-py3-none-any.whl
| Download URL | tatuarvela_magic-3.1.3-py3-none-any.whl |
|---|---|
| Size | 13.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b97881cb7b2307c5a9fdfe5187e586650ee0104a7cba36a2872c92fba8c42ad8
|
|
BLAKE2b-256 checksum How to use checksums |
69e332ac59c479c22c54171948e80b754f6e6084a38b3b0178c3803f432d17dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.9.10 Linux/5.11.0-1028-azure
|