Skip to main content

Shell helper utilities for python

Project description

shil     
Shell-util library for python. Includes helpers for subprocess invocation, shell-formatters / pretty-printers, and more.


Overview

The shil library provides various shell-utilities for python.

Features

  • Helpers for subprocess invocation
  • Shell-formatters / pretty-printers
  • A somewhat usable parser / grammer for bash
  • Support or rich protocols

Installation

See pypi for available releases.

pip install shil

Usage


See also:

import shil 
import json

# Working with models for Invocation/InvocationResponse:
req = cmd = shil.Invocation(command='ls /tmp')
resp = cmd()
print(resp.stdout)

# More functional approach:
resp = shil.invoke('ls /tmp')

# Loading data when command-output is JSON
req = cmd = shil.Invocation(command='echo {"foo":"bar"}')
resp = cmd()
print(resp.data)
assert type(resp.data)==type({})

# Uses pydantic, so serialization is straightforward
json.loads(resp.json())
json.loads(req.json())
for k,v in req.dict().items():
  assert getattr(resp,k)==v

# Rich console output for Invocations and InvocationResponse
import rich
rich.print(resp)

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

shil-2023.7.15.12.33.tar.gz (9.5 kB view hashes)

Uploaded Source

Built Distribution

shil-2023.7.15.12.33-py3-none-any.whl (12.4 kB view hashes)

Uploaded Python 3

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