acatton / python-spm

:muscle: Simple and secure sub processes manager
https://python-spm.readthedocs.org/en/latest/
MIT License
10 stars 3 forks source link

Interface improvement idea #1

Closed gavinwahl closed 9 years ago

gavinwahl commented 9 years ago

It seems to me that run and pipe are redundant. Running a single command is a special case of a pipeline. I think an interface like this would make sense:

Replace run('ls', '-l') with pipe(['ls', '-l'])

Replace pipe([['ls', '-l'], ['grep', 'foo']]) with pipe(['ls', '-l'], ['grep'], ['foo']])

acatton commented 9 years ago

See d6fcaf273ff0fb.

pipe() calls run() to get the first process of the pipe list. This makes this code readable IMHO, I'm not very seduced by the idea of having run() call pipe().

gavinwahl commented 9 years ago

pipe could just as easily call Subprocess. I'm not suggesting that run calls pipe, I'm say they're redundant and the public api should only have one function.

acatton commented 9 years ago

As I said, I don't want spm to be a library only for piping subprocesses. And having only pipe() as a public API would suggest that.

Second of all, run() has a nice interface which uses positional arguments, like this (i.e run('foo', 'bar')) this allows things like this:

import spm
import functools

git = functools.partial(spm.run, 'git')
git('commit').wait()

Using pipe() in order to run a simple command would remove this feature.

I think pipe() and run() is a nice public API. Reopen this issue if you think I'm wrong.

Thanks.