{"id":18085053,"url":"https://github.com/jwodder/patharg","last_synced_at":"2025-04-12T20:11:28.600Z","repository":{"id":153607579,"uuid":"629733937","full_name":"jwodder/patharg","owner":"jwodder","description":"Treat \"-\" (hyphen/dash) arguments as stdin/stdout","archived":false,"fork":false,"pushed_at":"2024-02-10T18:11:18.000Z","size":70,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-10T22:56:02.379Z","etag":null,"topics":["args","argv","available-on-crates-io","rust","stdin","stdout"],"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/jwodder.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2023-04-18T23:23:20.000Z","updated_at":"2023-12-18T12:58:55.000Z","dependencies_parsed_at":"2023-06-18T16:17:10.312Z","dependency_job_id":"0b86d230-542d-445d-be5c-b4ab7a9132e4","html_url":"https://github.com/jwodder/patharg","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fpatharg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fpatharg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fpatharg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fpatharg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwodder","download_url":"https://codeload.github.com/jwodder/patharg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625493,"owners_count":21135513,"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":["args","argv","available-on-crates-io","rust","stdin","stdout"],"created_at":"2024-10-31T15:09:13.602Z","updated_at":"2025-04-12T20:11:28.551Z","avatar_url":"https://github.com/jwodder.png","language":"Rust","readme":"[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![CI Status](https://github.com/jwodder/patharg/actions/workflows/test.yml/badge.svg)](https://github.com/jwodder/patharg/actions/workflows/test.yml)\n[![codecov.io](https://codecov.io/gh/jwodder/patharg/branch/master/graph/badge.svg)](https://codecov.io/gh/jwodder/patharg)\n[![Minimum Supported Rust Version](https://img.shields.io/badge/MSRV-1.78-orange)](https://www.rust-lang.org)\n[![MIT License](https://img.shields.io/github/license/jwodder/patharg.svg)](https://opensource.org/licenses/MIT)\n\n[GitHub](https://github.com/jwodder/patharg) | [crates.io](https://crates.io/crates/patharg) | [Documentation](https://docs.rs/patharg) | [Issues](https://github.com/jwodder/patharg/issues) | [Changelog](https://github.com/jwodder/patharg/blob/master/CHANGELOG.md)\n\nMost CLI commands that take file paths as arguments follow the convention of\ntreating a path of `-` (a single hyphen/dash) as referring to either standard\ninput or standard output (depending on whether the path is read from or written\nto).  The `patharg` crate lets your programs follow this convention too: it\nprovides `InputArg` and `OutputArg` types that wrap command-line arguments,\nwith methods for reading from/writing to either the given path or — if the\nargument is just a hyphen — the appropriate standard stream.\n\n`InputArg` and `OutputArg` implement `From\u003cOsString\u003e`, `From\u003cString\u003e`, and\n`FromStr`, so you can use them seamlessly with your favorite Rust source of\ncommand-line arguments, be it [`clap`][], [`lexopt`][], plain old\n[`std::env::args`][args]/[`std::env::args_os`][args_os], or whatever else is\nout there.  The source repository contains examples of two of these:\n\n- [`examples/flipcase.rs`][flipcase] and\n  [`examples/tokio-flipcase.rs`][tokio-flipcase] show how to use this crate\n  with `clap`.\n- [`examples/revchars.rs`][revchars] and\n  [`examples/tokio-revchars.rs`][tokio-revchars] show how to use this crate\n  with `lexopt`.\n\n[`clap`]: https://crates.io/crates/clap\n[`lexopt`]: https://crates.io/crates/lexopt\n[args]: https://doc.rust-lang.org/std/env/fn.args.html\n[args_os]: https://doc.rust-lang.org/std/env/fn.args_os.html\n[flipcase]: https://github.com/jwodder/patharg/blob/master/examples/flipcase.rs\n[tokio-flipcase]: https://github.com/jwodder/patharg/blob/master/examples/tokio-flipcase.rs\n[revchars]: https://github.com/jwodder/patharg/blob/master/examples/revchars.rs\n[tokio-revchars]: https://github.com/jwodder/patharg/blob/master/examples/tokio-revchars.rs\n\nComparison with clio\n====================\n\nThe only other library I am aware of that provides similar functionality to\n`patharg` is [`clio`][].  Compared to `clio`, `patharg` aims to be a much\nsimpler, smaller library that doesn't try to be too clever.  Major differences\nbetween the libraries include:\n\n- When a `clio` path instance is created, `clio` will either (depending on the\n  type used) open the path immediately — which can lead to empty files being\n  needlessly left behind if an output file is constructed during argument\n  processing but an error occurs before the file is actually used — or else\n  check that the path can be opened — which is vulnerable to TOCTTOU bugs.\n  `patharg` does no such thing.\n\n- `clio` supports reading from \u0026 writing to HTTP(S) URLs and has special\n  treatment for FIFOs.  `patharg` sees no need for such excesses.\n\n- `patharg` has a feature for allowing async I/O with [`tokio`][].  `clio` does\n  not.\n\n- `patharg` has optional support for [`serde`][].  `clio` does not.\n\n[`clio`]: https://crates.io/crates/clio\n[`tokio`]: https://crates.io/crates/tokio\n[`serde`]: https://crates.io/crates/serde\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwodder%2Fpatharg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwodder%2Fpatharg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwodder%2Fpatharg/lists"}