fabiopelosin / act

MIT License
55 stars 5 forks source link

Support reading from stdin #1

Closed kylef closed 10 years ago

kylef commented 10 years ago

This would be awesome for piping from other tools (the unix philosophy). If the content-type is missing, it could use the pygments "guess" API which uses some rules to guess content, like shebang lines, imports, <html> etc.

Example usage:

curl

Useful if you need to run curl to add a bunch of headers

$ curl -H 'Accepts: application/json' -H 'Authorization: Bearer [redacted token]' -H 'Authentication: Simple [redacted token]' '[redacted URI]' | act json

less

$ lessc styles.less | act css

jinja2

$ cat data.json | jinja2 index.html | act html

xcpretty

No idea why you'd do this, maybe for debugging

$ xcpretty -r junit | act xml
fabiopelosin commented 10 years ago

It should work like the following example, making this tool a barebones https://github.com/jakubroztocil/httpie :smile:

$ curl https://api.github.com/repos/CocoaPods/CocoaPods 2>/dev/null | act --lexer=json --prettify

{
  "id": 2203645,
  "name": "CocoaPods",
  "full_name": "CocoaPods/CocoaPods",
  "owner": {
    "login": "CocoaPods",
    "id": 1189714,
    "avatar_url": "https://avatars.githubusercontent.com/u/1189714?",
    "gravatar_id": "8b374a26ac900a5c7b83a8767faff333",
    "url": "https://api.github.com/users/CocoaPods",
    "html_url": "https://github.com/CocoaPods",
    "followers_url": "https://api.github.com/users/CocoaPods/followers",
    "following_url": "https://api.github.com/users/CocoaPods/following{/other_user}",
    "gists_url": "https://api.github.com/users/CocoaPods/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/CocoaPods/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/CocoaPods/subscriptions",
    "organizations_url": "https://api.github.com/users/CocoaPods/orgs",
    "repos_url": "https://api.github.com/users/CocoaPods/repos",
    "events_url": "https://api.github.com/users/CocoaPods/events{/privacy}",
    "received_events_url": "https://api.github.com/users/CocoaPods/received_events",
    "type": "Organization",
    "site_admin": false
...