{"id":13611801,"url":"https://github.com/z5labs/pflag","last_synced_at":"2025-04-13T05:33:40.227Z","repository":{"id":57654595,"uuid":"293393466","full_name":"z5labs/pflag","owner":"z5labs","description":"A crate implementing POSIX/GNU-style --flags.","archived":false,"fork":false,"pushed_at":"2020-10-22T17:03:10.000Z","size":44,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-26T05:23:41.369Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/z5labs.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":"2020-09-07T01:31:32.000Z","updated_at":"2022-07-21T07:58:14.000Z","dependencies_parsed_at":"2022-09-01T01:40:51.990Z","dependency_job_id":null,"html_url":"https://github.com/z5labs/pflag","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z5labs%2Fpflag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z5labs%2Fpflag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z5labs%2Fpflag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z5labs%2Fpflag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/z5labs","download_url":"https://codeload.github.com/z5labs/pflag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670513,"owners_count":21142896,"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-08-01T19:02:09.574Z","updated_at":"2025-04-13T05:33:38.464Z","avatar_url":"https://github.com/z5labs.png","language":"Rust","funding_links":[],"categories":["Libraries","Rust"],"sub_categories":["Command-line"],"readme":"[![Documentation](https://docs.rs/pflag/badge.svg)](https://docs.rs/pflag)\n\n# pflag\n\n`pflag` is a port of the [spf13](https://github.com/spf13/pflag)'s popular fork of the\nGo package by the same name.\n\n## Usage\n\n```rust\nuse pflag::{FlagSet, Slice};\nuse std::net::{IpAddr, Ipv4Addr};\n\nlet mut flags = FlagSet::new(\"name\");\n\n// Use higher level methods over add_flag directly.\nflags.int8(\"num\", 0, \"a flag for a number\");\nflags.string_p(\"str\", 's', String::from(\"default value\"), \"a flag for a String and has a shorthand\");\nflags.ip_addr_slice(\n    \"addrs\",\n    Slice::from([IpAddr::V4(Ipv4Addr::new(0,0,0,0)), IpAddr::V4(Ipv4Addr::new(127,0,0,1))]),\n    \"a multi-valued flag\",\n);\n\nlet args = \"--num=1 -s world --addrs 192.168.1.1,192.168.0.1 --addrs=127.0.0.1 subcommand\";\nif let Err(err) = flags.parse(args.split(' ')) {\n    panic!(err);\n}\n\n// Retrieving value is very easy with the value_of method.\nassert_eq!(*flags.value_of::\u003ci8\u003e(\"num\").unwrap(), 1);\nassert_eq!(*flags.value_of::\u003cString\u003e(\"str\").unwrap(), \"world\");\nassert_eq!(flags.value_of::\u003cSlice\u003cIpAddr\u003e\u003e(\"addrs\").unwrap().len(), 3);\n\n// Any non-flag args i.e. positional args can be retrieved by...\nlet args = flags.args();\nassert_eq!(args.len(), 1);\nassert_eq!(args[0], \"subcommand\");\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fz5labs%2Fpflag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fz5labs%2Fpflag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fz5labs%2Fpflag/lists"}