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:
@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
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
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_spec_mod-0.0.3.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for xontrib_spec_mod-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b50f221667a045cc8577e0d61f8eae9059eb51cc7bc0b182b3d97d0eb7248dac |
|
MD5 | 285b4f9c4207034379c8f28f620c783f |
|
BLAKE2b-256 | be33555e5153d7a791dc67165c84f49bbdc23457de46fb462586c091e1f3087c |