{"id":30437437,"url":"https://github.com/alexeev-prog/input_parser.cpp","last_synced_at":"2025-10-29T06:42:37.226Z","repository":{"id":308586349,"uuid":"1033346049","full_name":"alexeev-prog/input_parser.cpp","owner":"alexeev-prog","description":"A Simple Argument Input Parser in C++","archived":false,"fork":false,"pushed_at":"2025-08-06T17:36:33.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-06T19:26:23.589Z","etag":null,"topics":["argument-parser","argument-parsing","cli","cli-app","command-line","command-line-parser","cpp","cpp-library","cpp17","cpp20"],"latest_commit_sha":null,"homepage":"https://alexeev-prog.github.io/input_parser.cpp/","language":"HTML","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/alexeev-prog.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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-06T17:08:19.000Z","updated_at":"2025-08-06T17:38:26.000Z","dependencies_parsed_at":"2025-08-06T19:40:09.680Z","dependency_job_id":null,"html_url":"https://github.com/alexeev-prog/input_parser.cpp","commit_stats":null,"previous_names":["alexeev-prog/input_parser.cpp"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/alexeev-prog/input_parser.cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexeev-prog%2Finput_parser.cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexeev-prog%2Finput_parser.cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexeev-prog%2Finput_parser.cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexeev-prog%2Finput_parser.cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexeev-prog","download_url":"https://codeload.github.com/alexeev-prog/input_parser.cpp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexeev-prog%2Finput_parser.cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271740138,"owners_count":24812636,"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","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"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":["argument-parser","argument-parsing","cli","cli-app","command-line","command-line-parser","cpp","cpp-library","cpp17","cpp20"],"created_at":"2025-08-23T03:49:33.299Z","updated_at":"2025-10-29T06:42:32.160Z","avatar_url":"https://github.com/alexeev-prog.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# input_parser.cpp\nA lightweight, robust library for parsing command-line arguments with strict validation and automatic help generation.\n\n## Features\n- Support for both short (`-h`) and long (`--help`) options\n- Options with required/optional arguments\n- Positional arguments handling\n- Strict input validation with detailed error reporting\n- Automatic help message generation\n- Zero external dependencies (except STL and Abseil for string utilities)\n- Thread-safe implementation\n\n## Requirements\n- C++17 compatible compiler\n- CMake 3.12+ (optional for integration)\n- Abseil library (for string utilities)\n\n## Integration\n1. Copy `input_parser.hpp` and `input_parser.cpp` to your project's include directory\n2. Include in your code:\n```cpp\n#include \"input_parser.hpp\"\n```\n\n### Building as Static Library\n```bash\ngit clone https://github.com/alexeev-prog/input_parser.cpp\ncd input_parser\nmake\nsudo make install  # Installs to /usr/local by default\n```\n\n## Usage\n### Basic Example\n```cpp\n#include \"input_parser.hpp\"\n\nint main(int argc, char** argv) {\n    InputParser parser(\"myapp\", \"Sample application with argument parsing\");\n\n    // Register options\n    parser.add_option({\n        .short_name = \"-v\",\n        .long_name = \"--verbose\",\n        .description = \"Enable verbose output\",\n        .requires_argument = false\n    });\n\n    parser.add_option({\n        .short_name = \"-f\",\n        .long_name = \"--file\",\n        .description = \"Input file path\",\n        .requires_argument = true,\n        .arg_placeholder = \"PATH\"\n    });\n\n    // Parse arguments\n    if (!parser.parse(argc, argv)) {\n        for (const auto\u0026 error : parser.get_errors()) {\n            std::cerr \u003c\u003c \"ERROR: \" \u003c\u003c error \u003c\u003c \"\\n\";\n        }\n        std::cerr \u003c\u003c parser.generate_help();\n        return 1;\n    }\n\n    // Check options\n    if (parser.has_option(\"--verbose\")) {\n        std::cout \u003c\u003c \"Verbose mode enabled\\n\";\n    }\n\n    if (auto file_path = parser.get_argument(\"-f\")) {\n        std::cout \u003c\u003c \"Processing file: \" \u003c\u003c *file_path \u003c\u003c \"\\n\";\n    }\n\n    return 0;\n}\n```\n\n### Supported Syntax Formats\n1. Short options:\n   ```bash\n   ./app -v -f data.txt\n   ```\n2. Long options:\n   ```bash\n   ./app --verbose --file=data.txt\n   ```\n3. Mixed formats:\n   ```bash\n   ./app -v --file data.txt\n   ```\n4. Positional arguments:\n   ```bash\n   ./app input.dat -v\n   ```\n\n## API Reference\n### `InputParser` Class\n| Method | Description |\n|--------|-------------|\n| `add_option(const Option\u0026)` | Register new command-line option |\n| `parse(int, char**)` | Parse command-line arguments |\n| `has_option(string)` | Check if option was provided |\n| `get_argument(string)` | Get argument for option |\n| `get_positional_args()` | Get non-option arguments |\n| `get_errors()` | Get parsing errors |\n| `generate_help()` | Generate help message |\n\n### `Option` Structure\n| Field | Description |\n|-------|-------------|\n| `short_name` | Short option name (e.g., \"-v\") |\n| `long_name` | Long option name (e.g., \"--verbose\") |\n| `description` | Help text description |\n| `requires_argument` | Whether option requires argument |\n| `arg_placeholder` | Argument placeholder for help |\n\n## Error Handling\nThe parser collects all errors during parsing. Common errors include:\n- Unknown options\n- Missing required arguments\n- Unexpected arguments for options\n- Duplicate option declarations\n\n## License\nMIT License. See LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexeev-prog%2Finput_parser.cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexeev-prog%2Finput_parser.cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexeev-prog%2Finput_parser.cpp/lists"}