Skip to main content

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 Python dict.
  • @path - string to pathlib.Path.

Extra decorators:

xpip install 'xontrib-dalias[dict,yaml]'
  • @dict - dict-like object (json, JavaScript object, Python dict) to Python dict.
  • @yaml - YAML to Python dict.

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


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)

Uploaded Source

Built Distribution

xontrib_dalias-0.0.6-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

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

Hashes for xontrib_dalias-0.0.6.tar.gz
Algorithm Hash digest
SHA256 c3672b6fc9db5257c1f8e88981060429d1139186cf1cfe061d5200b89c555667
MD5 56297eb62ce90121075cb9dd7b6413a6
BLAKE2b-256 a9df55e3f5d3e2aaff8029dce8eca8221693d51507726bd998dcb2c94c8d5c44

See more details on using hashes here.

File details

Details for the file xontrib_dalias-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for xontrib_dalias-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9ce75bd8e45806fc76d67faeac95b2ed9ecacd159d9af0bb3620b4a07a5e3986
MD5 f171146766c8b75d53b4ad2d530b1841
BLAKE2b-256 05b4719bfdb7cbb3c1172ed14c1737d8d155421c1b916885c16f7b5e69ae68fb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page