wip: generate python scripts from (s)hell pipelines
Go to file
NotAFile 750c8d3e28 add non-raw jq option 2021-09-29 17:37:36 +02:00
hellpipe add non-raw jq option 2021-09-29 17:37:36 +02:00
.gitignore Initial commit 2021-09-29 16:06:01 +02:00
README.md add jq and curl headers 2021-09-29 17:29:52 +02:00
pyproject.toml initial commit 2021-09-29 16:09:45 +02:00

README.md

hellpipe

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.

Example

curl "https://httpbin.org/get?test=123" | jq ".headers|keys[]" -r | xargs -L 1 echo

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

  • curl -> requests (very basic)
  • xargs (only prints)
  • shell commands (no stderr capture)
  • jq via bindings
  • head/tail
  • sort
  • basic shell loops