A lightweight C++ library for parsing command-line arguments
- Supports short flags (
-f) and long flags (--flag) - Stores the main run argument (
runArg) - Auto-generates help messages
- Minimal and lightweight implementation with no dependencies
g++ -o my_program main.cpp tinyArgs.cpp#include "tinyArgs.hpp"
#include <iostream>
int main(int argc, char* argv[]) {
targs::TinyArgs args(argc, argv);
if (args.getShortFlag("-h", "Show help message")) {
std::cout << args.help();
return 0;
}
std::string filename = args.getShortFlagValue("-f", "Input file name");
if (!filename.empty()) {
std::cout << "Reading from file: " << filename << std::endl;
}
return 0;
}./my_program -hOutput:
-h -> Show help message
-f -> Input file name
Description: Constructor that processes command-line arguments.
Description: Returns the value of a short flag (-f).
Description: Checks if a short flag (-h) is set.
Description: Returns the first non-flag argument (main program parameter).
Description: Returns a help message listing all flags and descriptions.
Feel free to submit a pull request if you have suggestions for improving TinyArgs!
TinyArgs is released under the GNU General Public License v3.0 (GPL-3.0). See LICENSE for more details.