{"id":50943626,"url":"https://github.com/alexjackson1/take_bytes","last_synced_at":"2026-06-17T17:35:58.007Z","repository":{"id":356112046,"uuid":"1142342616","full_name":"alexjackson1/take_bytes","owner":"alexjackson1","description":"A lightweight Rust utility for classic Unix-style CLIs","archived":false,"fork":false,"pushed_at":"2026-01-26T09:33:17.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-06T18:26:54.394Z","etag":null,"topics":["clap-rs","rust","unix"],"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/alexjackson1.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-26T09:31:00.000Z","updated_at":"2026-01-26T15:07:07.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/alexjackson1/take_bytes","commit_stats":null,"previous_names":["alexjackson1/take_bytes"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/alexjackson1/take_bytes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexjackson1%2Ftake_bytes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexjackson1%2Ftake_bytes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexjackson1%2Ftake_bytes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexjackson1%2Ftake_bytes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexjackson1","download_url":"https://codeload.github.com/alexjackson1/take_bytes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexjackson1%2Ftake_bytes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34459608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["clap-rs","rust","unix"],"created_at":"2026-06-17T17:35:57.439Z","updated_at":"2026-06-17T17:35:58.001Z","avatar_url":"https://github.com/alexjackson1.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# take_bytes\n\nA lightweight Rust utility for reading input from stdin or a file path, designed for seamless integration with [clap](https://github.com/clap-rs/clap)'s derive API.\n\n## Features\n\n- **Simple API**: Just parse `\"-\"` for stdin or any path for file input\n- **Clap Integration**: Implements `FromStr` for direct use as a clap argument type\n- **Zero Configuration**: Works out of the box with sensible defaults\n- **Lightweight**: Minimal dependencies\n\n## Installation\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\ntake_bytes = \"0.1\"\n```\n\nThe `clap` feature is enabled by default. To use without clap:\n\n```toml\n[dependencies]\ntake_bytes = { version = \"0.1\", default-features = false }\n```\n\n## Usage\n\n### With Clap\n\n```rust\nuse clap::Parser;\nuse take_bytes::TakeBytes;\n\n#[derive(Parser)]\nstruct Cli {\n    /// Input file or \"-\" for stdin\n    #[arg(default_value = \"-\")]\n    input: TakeBytes,\n}\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let cli = Cli::parse();\n    \n    // Read as bytes\n    let bytes = cli.input.try_into_bytes()?;\n    println!(\"Read {} bytes\", bytes.len());\n    \n    Ok(())\n}\n```\n\n### Programmatic Use\n\n```rust\nuse take_bytes::TakeBytes;\nuse std::path::PathBuf;\n\n// Read from stdin\nlet stdin_input = TakeBytes::stdin();\n\n// Read from a file\nlet file_input = TakeBytes::file(PathBuf::from(\"input.txt\"));\n\n// Parse from string (like clap does)\nlet input: TakeBytes = \"-\".parse()?;\n```\n\n### Helper Functions\n\n```rust\nuse take_bytes::{TakeBytes, read_as_bytes, decode_utf8_string};\n\nlet input: TakeBytes = \"file.txt\".parse()?;\n\n// Read as raw bytes\nlet bytes = read_as_bytes(input)?;\n\n// Or decode as UTF-8 string\nlet input: TakeBytes = \"file.txt\".parse()?;\nlet text = decode_utf8_string(input)?;\n```\n\n## Examples\n\nThe classic Unix pattern of accepting input from either a file or stdin:\n\n```bash\n# Read from a file\nmyapp input.txt\n\n# Read from stdin\ncat input.txt | myapp -\n\n# Read from stdin (default)\necho \"hello\" | myapp\n```\n\n## License\n\nMIT License - see [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexjackson1%2Ftake_bytes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexjackson1%2Ftake_bytes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexjackson1%2Ftake_bytes/lists"}