hellpipe/README.md

58 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2021-09-29 14:06:01 +00:00
# hellpipe
2021-09-29 14:20:35 +00:00
wip: generate python scripts from (s)hell pipelines
Intended to be used with a shell plugin to make those oneliners that get out of hand more manageable.
2021-09-29 16:59:26 +00:00
An example plugin for fish is provided in hellpipe.fish.
2021-09-29 14:20:35 +00:00
## Example
`curl "https://httpbin.org/get?test=123" | jq ".headers|keys[]" -r | xargs -L 1 echo`
```python
import requests
import subprocess
import sys
import shlex
# generated with hellpipe
def main():
params = {"test": ["123"]}
res = requests.get("https://httpbin.org/get", params=params).text
proc = subprocess.Popen(
["jq", ".headers|keys[]", "-r"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=sys.stderr,
)
(stdout, _) = proc.communicate(res.encode("utf-8"))
out_jq = stdout.decode("utf-8")
for i in shlex.split(out_jq, posix=True):
print(i) # TODO
if __name__ == "__main__":
main()
```
## Currently Supported Mappings
- [x] curl -> requests (very basic)
- [ ] xargs (only prints)
- [x] shell commands (no stderr capture)
2021-09-29 15:29:52 +00:00
- [x] jq via bindings
2021-09-29 16:01:12 +00:00
- [ ] grep
2021-09-29 14:20:35 +00:00
- [ ] head/tail
- [ ] sort
- [ ] basic shell loops
2021-09-29 16:01:12 +00:00
- [ ] shell globs
- [ ] file operations (mv, cp, rm, ls)
- [ ] cat
- [ ] sed
- [ ] trim
- [ ] subshell