Library of xonsh subprocess specification modifiers.
Project description
Library of xonsh subprocess specification modifiers.
If you like the idea click ⭐ on the repo and tweet.
Installation
To install use pip:
xpip install xontrib-spec-mod
xpip install 'xontrib-spec-mod[dict,yaml]' # Additional modifiers.
Load:
xontrib load spec_mod
Usage
Transform output to object
Modifiers:
@lines
- return list of lines.@json
- json to Pythondict
.@dict
- dict-like object (json, JavaScript object, Python dict) to Pythondict
. Install extra support viaxpip install 'xontrib-spec-mod[dict]'
.@path
- string topathlib.Path
.@yaml
- YAML to Pythondict
. Installxpip install 'xontrib-spec-mod[yaml]'
.
Examples:
$(@lines ls /)
# ['/bin', '/etc', '/home']
$(@json echo '{"a":1}') # Try with `curl` ;)
# dict({"a":1})
$(@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
Modifiers:
@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
Development
# install pre-commit plugins and activate the commit hook
pre-commit install
pre-commit autoupdate
Credits
This package was created with xontrib template.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xontrib_spec_mod-0.0.2.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for xontrib_spec_mod-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 359798fe3d55ebb5c097b95a5bec022e4ff25d613b58bf6e889a24992a621bf4 |
|
MD5 | 58eec71384f9a59d12ae1a136a376917 |
|
BLAKE2b-256 | 9487aed0154ed6853138403b3b0a8cfbdc70d3f58b57f5e8a045d357bee874fb |