{"id":16475970,"url":"https://github.com/softprops/pine","last_synced_at":"2025-03-23T11:32:54.792Z","repository":{"id":57655311,"uuid":"42834870","full_name":"softprops/pine","owner":"softprops","description":"process line output","archived":false,"fork":false,"pushed_at":"2015-10-24T20:00:27.000Z","size":744,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T11:59:59.269Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/softprops.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-21T00:15:31.000Z","updated_at":"2019-08-18T16:52:01.000Z","dependencies_parsed_at":"2022-09-01T14:10:41.011Z","dependency_job_id":null,"html_url":"https://github.com/softprops/pine","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fpine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fpine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fpine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fpine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softprops","download_url":"https://codeload.github.com/softprops/pine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245097158,"owners_count":20560311,"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":[],"created_at":"2024-10-11T12:41:05.812Z","updated_at":"2025-03-23T11:32:54.424Z","avatar_url":"https://github.com/softprops.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pine\n\n[![Build Status](https://travis-ci.org/softprops/pine.svg?branch=master)](https://travis-ci.org/softprops/pine) [![crates.io](http://meritbadge.herokuapp.com/pine)](https://crates.io/crates/pine)\n\n\u003e line oriented process output\n\n## install\n\nAdd the following to your Cargo.toml file\n\n```toml\n[dependencies]\npine = \"0.1\"\n```\n\n## apidocs\n\nFind them [here](http://softprops.github.io/pine)\n\n## usage\n\nRust's interface for working with [processes](https://doc.rust-lang.org/std/process/) is pretty great, but sometimes\nyou may wish to stream process output as it becomes available rather waiting for the process to exit before you can get\na handle on the total process [output](https://doc.rust-lang.org/std/process/struct.Output.html).\n\nFor these usecases, `pine` provides in iterator interface over lines of process output,\nrepresented as enum of `pine::Line::StdOut` or `pine::Line::StdErr`. This is well suited for unix programs with emit\nline-oriented output. A prerequite for your program to gain access\nto these lines of output, is making sure your child process output is \"piped\" to your program. Rust's Command interface\nmakes this simple.\n\n```rust\nextern crate pine;\nuse std::process::{Command, Stdio};\n\nlet mut process = Command::new(\"/bin/sh\")\n    .arg(\"-c\")\n    .arg(\"curl https://www.howsmyssl.com/a/check\")\n    .stdout(Stdio::piped())\n    .stderr(Stdio::piped())\n    .spawn().ok().unwrap();\n```\n\nWith the child's output piped to your program, you can then iterate over lines of output as\nthey are available. using the `pine::lines` function.\n\n```rust\nuse pine::Line;\nlet lines = pine::lines(\u0026mut process);\nfor line in lines.iter() {\n    match line {\n        Line::StdOut(line) =\u003e println!(\"out -\u003e {}\", line),\n        Line::StdErr(line) =\u003e println!(\"err -\u003e {}\", line)\n    }\n}\n```\n\nNote `iter()` returns an iterator, which means any functions defined on iterator are\nat your disposal for processing line output.\n\nDoug Tangren (softprops) 2015\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftprops%2Fpine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftprops%2Fpine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftprops%2Fpine/lists"}