From e80d501891ba58f56b6d714ed438588aa968448c Mon Sep 17 00:00:00 2001 From: Tilo-K Date: Fri, 20 Jun 2025 16:03:25 +0200 Subject: [PATCH] README and LICENSE --- LICENSE.md | 21 +++++++++++++++++++++ README.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..8aa232d --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Tilo Klarenbeek + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 0ee24bb..40ed2a1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,58 @@ +# SeaFlags: A Simple C Library for Command Line Argument Parsing +
SeaFlags Logo
-### SeaFlags is a simple library for parsing command line arguments. +SeaFlags is a straightforward C library designed for parsing command-line arguments. It offers a simple and efficient way for developers to manage flags and options in their C applications, making command-line interfaces easier to build and maintain. + +## Features + +* **Simplified API:** Easy-to-use functions for defining and parsing flags. +* **Flexible Flag Support:** Handles both short (`-s`) and long (`--long`) argument formats. + +* **Error Reporting:** Provides clear feedback on parsing issues. + +## Getting Started + +Here's a basic example demonstrating how to parse a string argument: + +```c +#include +#include // Required for printf + +int main(int argc, char** argv) { + struct SeaFlagSet flags; + // Initialize with program info: name, version, author, description + seaflags_init(&flags, "Sea Flag Example", "0.0.0", "Tilo" , "Example for the seaflags library"); + + char* name = NULL; // Variable to store the parsed --name argument + + // Add a flag: long_name, short_name, is_required, pointer_to_store_value + seaflags_add_flag(&flags, "--name", "-n", true, &name); + + // Parse the command line arguments + int result = seaflags_parse(&flags, argc, argv); + + if (result != 0) { + fprintf(stderr, "Error parsing flags.\n"); // SeaFlags typically prints error details too + return 1; + } + + // Access the parsed argument + printf("Hello, %s!\n", name); + seaflags_free(&flags); // Free the memory allocated by SeaFlags + + return 0; +} +``` + +## Contributing + +Contributions are welcome. Please refer to the [Code of Conduct](https://tilok.dev/coc). + +## License + +This project is licensed under the MIT License. See the `LICENSE` file for details.