Object-oriented commandline
Project description
Object oriented commandline
Install
pip install spall
Development
poetry install
Example Usage
from spall import Subprocess
cmd = str(...) # any command here e.g. git
proc = Subprocess(cmd) # instantiate executable as object
passing = ... # insert passing command here
returncode = proc.call(passing) # this will print to console
print(returncode) # -> 0
proc.call(passing, capture=True) # this will record the output
proc.stdout() # -> [...]
# stdout is consumed
proc.stdout() # -> []
# this will record the output twice
proc.call(passing, capture=True)
proc.call(passing, capture=True)
proc.stdout() # -> [..., ...]
proc.stdout() # -> []
# this will redirect stdout to /dev/null
proc.call(passing, devnull=True)
# this will pipe stdout to file
proc.call(file="~/example.txt")
failing = ... # insert failing command here
# will raise a ``subprocess.CalledProcessError``
returncode = proc.call(failing)
print(returncode) # -> > 0
# this, however, will not
returncode = proc.call(failing, suppress=True)
print(returncode) # -> > 0
# all the keyword arguments above can be set as the default for the
# instantiated object
proc = Subprocess(cmd, capture=True)
proc.call(passing)
proc.stdout() # -> [...]
# but they will be overridden through the method
proc.call(passing, capture=False)
proc.stdout() # -> []
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
spall-0.1.1.tar.gz
(5.4 kB
view hashes)
Built Distribution
spall-0.1.1-py3-none-any.whl
(5.5 kB
view hashes)