Summary
Allow hulak to read a YAML request definition from stdin instead of requiring a file on disk.
Problem
Today, every request requires a .hk.yaml file. For one-off requests or automation, this means creating a temp file, running hulak, then cleaning up:
cat > /tmp/req.hk.yaml << 'EOF'
method: POST
url: https://api.example.com/users
body:
raw: '{"name": "John"}'
EOF
hulak -fp /tmp/req.hk.yaml
rm /tmp/req.hk.yaml
Proposed behavior
# Pipe YAML directly
echo 'method: GET
url: https://httpbin.org/get' | hulak --stdin
# Heredoc for multi-line
hulak --stdin << 'EOF'
method: POST
url: https://api.example.com/users
headers:
Content-Type: application/json
body:
raw: '{"name": "John"}'
EOF
# Combine with --quiet for full automation
cat request.yaml | hulak --stdin --quiet | jq '.response.body'
When --stdin is set:
- Read YAML from stdin instead of a file
- Parse it through the same
yamlparser pipeline as file-based requests
-env flag still works for template variable resolution
- No
_response.json file is saved (no source file to derive the name from), response goes to stdout only
Implementation notes
- The YAML parsing path already exists in
pkg/yamlparser/ — this just needs a new input source
- Detect stdin via
os.Stdin stat or the --stdin flag
- Template actions like
{{.token}} should still resolve from env files
- Actions like
{{getValueOf ...}} and {{getFile ...}} should still work (they reference the filesystem, not the input source)
Parent
Part of #154 — v0.3 ergonomics
Summary
Allow hulak to read a YAML request definition from stdin instead of requiring a file on disk.
Problem
Today, every request requires a
.hk.yamlfile. For one-off requests or automation, this means creating a temp file, running hulak, then cleaning up:Proposed behavior
When
--stdinis set:yamlparserpipeline as file-based requests-envflag still works for template variable resolution_response.jsonfile is saved (no source file to derive the name from), response goes to stdout onlyImplementation notes
pkg/yamlparser/— this just needs a new input sourceos.Stdinstat or the--stdinflag{{.token}}should still resolve from env files{{getValueOf ...}}and{{getFile ...}}should still work (they reference the filesystem, not the input source)Parent
Part of #154 — v0.3 ergonomics