{"id":23553359,"url":"https://github.com/geofmureithi/cmdpiped","last_synced_at":"2025-04-28T13:47:50.430Z","repository":{"id":49347912,"uuid":"517190380","full_name":"geofmureithi/cmdpiped","owner":"geofmureithi","description":"A command-line tool for exposing a wrapped program's standard IO using WebSockets/SSE","archived":false,"fork":false,"pushed_at":"2025-03-24T10:35:56.000Z","size":159,"stargazers_count":16,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T10:11:26.493Z","etag":null,"topics":["actix-web","daemon","sse","websocket"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geofmureithi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-24T00:09:14.000Z","updated_at":"2025-03-29T21:02:15.000Z","dependencies_parsed_at":"2025-02-21T10:28:50.281Z","dependency_job_id":"e86103d8-9786-4be8-8ffe-9cb75325c231","html_url":"https://github.com/geofmureithi/cmdpiped","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"b2aca1f5f0d3ba0283d9dbf32125857b05314013"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geofmureithi%2Fcmdpiped","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geofmureithi%2Fcmdpiped/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geofmureithi%2Fcmdpiped/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geofmureithi%2Fcmdpiped/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geofmureithi","download_url":"https://codeload.github.com/geofmureithi/cmdpiped/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251321951,"owners_count":21570825,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actix-web","daemon","sse","websocket"],"created_at":"2024-12-26T11:14:54.585Z","updated_at":"2025-04-28T13:47:50.410Z","avatar_url":"https://github.com/geofmureithi.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cmdpiped\n\n`cmdpiped` is a command-line tool for exposing a wrapped cli program's standard IO to WebSockets/SSE\n\n## Installation\n\nReady to use Binaries are available at the releases page.\n\nFor Rust users, you can always use cargo\n\n```\ncargo install cmdpiped\n```\n\n## Usage\n\n```\nUSAGE:\n    cmdpiped [OPTIONS] --mode \u003cMODE\u003e [SUBCOMMAND]\n\nOPTIONS:\n    -h, --host \u003cHOST\u003e      Host address to bind [default: 127.0.0.1]\n        --help             Print help information\n    -m, --mode \u003cMODE\u003e      Mode to expose events [possible values: ws, sse]\n    -p, --port \u003cPORT\u003e      Port to bind [default: 9000]\n        --path \u003cPATH\u003e      Url path to setup [default: /events]\n        --serve \u003cSERVE\u003e    Optional folder path to serve static files\n    -V, --version          Print version information\n```\n\nYou can also use piping\n\n```\n$ node ./index.js | cmdpiped -m sse\n```\n\n## Examples\n\n### Some Basic Examples\n\n`cmdpiped` is language agnostic and should be able to plugin easily for anything that can run on the command line.\n\n\u003cdetails\u003e\n  \u003csummary\u003ePython\u003c/summary\u003e\n\n```py\nfrom sys import stdout\nfrom time import sleep\n\n# Count to 100 sleeping every second\nfor count in range(0, 100):\n  print(count + 1)\n  stdout.flush()\n  sleep(1)\n```\n\nSave the file as `counter.py` and run the `cmdpiped`\n\n```\n$ cmdpiped -m sse python3 ./counter.py\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n  \u003csummary\u003eNode.js\u003c/summary\u003e\n\n```js\nlet count = 0;\n\nsetInterval(() =\u003e {\n  console.log(count++);\n}, 1000);\n```\n\nSave the file as `index.js` and run the `cmdpiped`\n\n```\n$ cmdpiped -m sse node ./index.js\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eBash\u003c/summary\u003e\n\n```sh\n#!/bin/bash\n\n# Count from 1 to 100 with a sleep of 1 second\nfor ((COUNT = 1; COUNT \u003c= 100; COUNT++)); do\n  echo $COUNT\n  sleep 1\ndone\n```\n\nSave the file as `script.sh` and run the `cmdpiped`\n\n```\n$ chmod +x ./script.sh\n$ cmdpiped -m sse ./script.sh\n```\n\n\u003c/details\u003e\n\nYou should be able to get:\n\n```\n[2022-07-24T13:41:11Z TRACE actix_server::worker] Service \"actix-web-service-127.0.0.1:9000\" is available\n[2022-07-24T13:41:11Z TRACE cmdpiped::broadcaster] Send: \"data: 1\\n\\n\"\n[2022-07-24T13:41:11Z TRACE cmdpiped::broadcaster] Send: \"data: 2\\n\\n\"\n[2022-07-24T13:41:12Z TRACE cmdpiped::broadcaster] Send: \"data: 3\\n\\n\"\n[2022-07-24T13:41:13Z TRACE cmdpiped::broadcaster] Send: \"data: 4\\n\\n\"\n...\n```\n\n### Advanced Example\n\nUsing the above example, we can add some frontend code\n\n1. Create a folder called `static`.\n2. Add an `index.html` file:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cscript type=\"text/javascript\"\u003e\n      var source = new EventSource(\"http://localhost:9000/events\");\n      source.onmessage = function (event) {\n        var content = document.getElementById(\"content\");\n        content.innerHTML = content.innerHTML + event.data + \"\u003cbr/\u003e\";\n      };\n    \u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cdiv id=\"content\"\u003e\u003c/div\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nRun `cmdpiped` exposing a directory\n\n```\n$ cmdpiped -m sse --serve ./static\n```\n\n### A complete example\n\nA complete example is available in the [examples](./examples/monitor/)\n\n![Complete Example](./examples/monitor/Screenshot.png)\n\n## Roadmap\n\n- [x] SSE Streaming\n- [x] Websocket Server -\u003e Client\n- [ ] Websocket Client -\u003e Server\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/geofmureithi/cmdpiped/tags).\n\n## Authors\n\n- **Njuguna Mureithi** - _Initial work_ - [Njuguna Mureithi](https://github.com/geofmureithi)\n\nSee also the list of [contributors](https://github.com/geofmureithi/cmdpiped/contributors) who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeofmureithi%2Fcmdpiped","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeofmureithi%2Fcmdpiped","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeofmureithi%2Fcmdpiped/lists"}