Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alex-sandalov/argumentparser
The ArgParser class facilitates command-line argument parsing, supporting boolean flags, integer arguments, and string arguments with optional short names and descriptions.
https://github.com/alex-sandalov/argumentparser
Last synced: 19 days ago
JSON representation
The ArgParser class facilitates command-line argument parsing, supporting boolean flags, integer arguments, and string arguments with optional short names and descriptions.
- Host: GitHub
- URL: https://github.com/alex-sandalov/argumentparser
- Owner: alex-sandalov
- License: mit
- Created: 2024-05-14T09:25:52.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-14T09:43:38.000Z (8 months ago)
- Last Synced: 2024-10-16T19:28:02.196Z (2 months ago)
- Language: C++
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ArgumentParser
The ArgParser class facilitates command-line argument parsing, supporting boolean flags, integer arguments, and string arguments with optional short names and descriptions.
## Features
## Features
**- Boolean Flags:** Add and parse boolean flags with short and long names.
**- Integer Arguments:** Handle integer arguments with optional descriptions.
**- String Arguments:** Manage string arguments with detailed descriptions.
**- Positional Arguments:** Support for positional arguments.
**- Flexible Parsing:** Easily parse command-line inputs and retrieve values.**
## Usage
```cpp
#include "ArgParser.h"int main(int argc, char* argv[]) {
ArgumentParser::ArgParser parser("ExampleParser");
auto& help = parser.AddFlag('h', "help", "Show help message");
auto& count = parser.AddIntArgument('c', "count", "Number of items");
auto& name = parser.AddStringArgument('n', "name", "Name of the user");if (!parser.Parse(std::vector(argv, argv + argc))) {
// Handle parsing error
}if (parser.GetFlag("help")) {
// Show help message
}int itemCount = parser.GetIntValue("count");
std::string userName = parser.GetStringValue("name");// Use parsed values
}
```## Installation
1. Clone the repository.
2. Include the necessary headers in your project.```
git clone https://github.com/alex-sandalov/ArgumentParser.git
```