Library of decorator aliases for the xonsh shell.
Project description
Library of decorator aliases (daliases) for the xonsh shell.
If you like the idea click ⭐ on the repo and tweet.
Installation
To install use pip:
xpip install xontrib-dalias
# or
xpip install 'xontrib-dalias[dict,yaml]' # Extra decorators.
Load:
xontrib load dalias
Usage
Transform output to object
Default decorators:
@lines
- return list of lines.@json
- json to Pythondict
.@path
- string topathlib.Path
.
Extra decorators:
xpip install 'xontrib-dalias[dict,yaml]'
@dict
- dict-like object (json, JavaScript object, Python dict) to Pythondict
.@yaml
- YAML to Pythondict
.
Examples
$(@lines ls /)
# ['/bin', '/etc', '/home']
$(@json echo '{"a":1}') # Try with `curl` ;)
# dict({"a":1})
docker inspect @($(@json docker ps --format json)['ID'])
# Container info
$(@path which xonsh)
# Path('/path/to/xonsh')
$(@path which xonsh).parent
# Path('/path/to')
aliases['ydig'] = '@yaml dig +yaml' # Update `dig` via `brew install bind` to have `+yaml`.
y = $(ydig google.com)
y[0]['type']
# 'MESSAGE'
Error handling
Default decorators:
@err
- set$RAISE_SUBPROC_ERROR=True
for the command.@noerr
- set$RAISE_SUBPROC_ERROR=False
for the command.
Examples:
$RAISE_SUBPROC_ERROR = True # General environment.
if ![@noerr ls nononofile]: # Do not raise exception in case of error.
echo file
Credits
This package was created with xontrib template.
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
xontrib_dalias-0.0.6.tar.gz
(4.6 kB
view details)
Built Distribution
File details
Details for the file xontrib_dalias-0.0.6.tar.gz
.
File metadata
- Download URL: xontrib_dalias-0.0.6.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3672b6fc9db5257c1f8e88981060429d1139186cf1cfe061d5200b89c555667 |
|
MD5 | 56297eb62ce90121075cb9dd7b6413a6 |
|
BLAKE2b-256 | a9df55e3f5d3e2aaff8029dce8eca8221693d51507726bd998dcb2c94c8d5c44 |
File details
Details for the file xontrib_dalias-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: xontrib_dalias-0.0.6-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ce75bd8e45806fc76d67faeac95b2ed9ecacd159d9af0bb3620b4a07a5e3986 |
|
MD5 | f171146766c8b75d53b4ad2d530b1841 |
|
BLAKE2b-256 | 05b4719bfdb7cbb3c1172ed14c1737d8d155421c1b916885c16f7b5e69ae68fb |