yrahul3910 / pysh

Embed bash in your Python
MIT License
0 stars 0 forks source link

Add async mode #9

Closed yrahul3910 closed 11 months ago

yrahul3910 commented 11 months ago

The new 1.2.3 release calls proc.wait(), which makes this synchronous. An async option should be provided.

yrahul3910 commented 11 months ago

We will need a change from the syntax proposed in #7. Specifically, attributes cannot be in square brackets, since we now allow custom formatters. Specifically, consider this:

a = 1
custom_formatters[a]`cat {file}`

should not treat a as an attribute. Instead, the new regex is here.

which moves the attributes to the very end of the regex, and uses curly braces, which are not valid Python. As such, the following are valid:

{a}`long_process`
list{b}`cat {file}`

where b might be a future attribute. Note that if we use async, we need to ensure that no formatter is used.