wip: generate python scripts from (s)hell pipelines
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
NotAFile 7602605cdf add original pipeline to output 1 year ago
hellpipe add original pipeline to output 1 year ago
.gitignore Initial commit 1 year ago
README.md add example fish plugin 1 year ago
hellpipe.fish add example fish plugin 1 year ago
pyproject.toml initial commit 1 year ago

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. An example plugin for fish is provided in hellpipe.fish.

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
  • grep
  • head/tail
  • sort
  • basic shell loops
  • shell globs
  • file operations (mv, cp, rm, ls)
  • cat
  • sed
  • trim
  • subshell