{"id":21864591,"url":"https://github.com/2004seraph/cyanargparser","last_synced_at":"2025-03-21T20:45:35.136Z","repository":{"id":54680116,"uuid":"519796167","full_name":"2004seraph/CyanArgParser","owner":"2004seraph","description":"Simple C++ argument parser","archived":false,"fork":false,"pushed_at":"2024-03-12T18:41:36.000Z","size":193,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-28T04:09:55.829Z","etag":null,"topics":["argument-parsing","library","toy-project"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/2004seraph.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":"2022-07-31T14:18:19.000Z","updated_at":"2024-03-12T18:38:20.000Z","dependencies_parsed_at":"2022-08-13T23:50:28.259Z","dependency_job_id":null,"html_url":"https://github.com/2004seraph/CyanArgParser","commit_stats":null,"previous_names":["2004seraph/cyanargparser"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2004seraph%2FCyanArgParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2004seraph%2FCyanArgParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2004seraph%2FCyanArgParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2004seraph%2FCyanArgParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2004seraph","download_url":"https://codeload.github.com/2004seraph/CyanArgParser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235721212,"owners_count":19035086,"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":["argument-parsing","library","toy-project"],"created_at":"2024-11-28T04:10:25.666Z","updated_at":"2025-01-26T15:26:00.834Z","avatar_url":"https://github.com/2004seraph.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CyanArgParser - My Argument Parser\n \nThis is a simple C++17 argument parser made mainly for my own use as well as practice, hence its design and featureset will probably only appease me. I have however attempted to make the interface as intuitive as possible.\n\n## How to use\n\nYou must always declare a parser instance, I like to enclose all of my code beneath my namespace `cyan` and then its library.\n\n```cpp\n#include \"argParser.hpp\"\n\n//You will probably find it convienent to use a namespace alias\nnamespace cap = cyan::argParser;\n\nint main(int argc, char* argv[]) {\n\tcap::Parser parser;\n}\n```\n\n#### Creating and customizing arguments\n\nYou create arguments be calling the `AddArgument` function of the parser instance, you then may call any number of optional functions on the argument itself to customize it.\n\n```cpp\nparser.AddArgument(\"verboseLogging\")//name of the setting\n    -\u003eAddAlias(\"--v\")//how it can be accessed from the command line\n    -\u003eAddAlias(\"--verbose\");//an alternate alias\n\nparser.AddArgument(\"writeToFile\")\n    -\u003eAddAlias(\"--f\");\n```\n\n#### Input\n\nCurrently the only other option is `SetInput`, which means the argument is accompanied with a string value from the command line. You must supply a default value in case it is unset.\n\n```cpp\nparser.AddArgument(\"memoryLimit\")\n    -\u003eAddAlias(\"--m\")\n    -\u003eSetInput(\"2048\");\n```\n\nArguments with values are set by default using the tilde character (~).\n\n```shell\napp.exe --m~1024\n```\n\nYou may change this character by using a parser constructor overload:\n\n```cpp\nint main(int argc, char* argv[]) {\n\tcap::Parser parser('=');\n}\n```\n\n#### Parsing arguments\n\nAfter declaring your arguments, you must then call the `Parse` function of the parser instance, passing in the main arguments. It will return an `std::map` of your schema that you can access.\n\n```cpp\nauto args = parser.Parse(argc, argv);\n\nif (args.at(\"verboseLogging\")-\u003eset) {\n    std::cout \u003c\u003c \"verbose is set\" \u003c\u003c std::endl;\n}\n\nif (args.at(\"writeToFile\")-\u003eset) {\n    std::cout \u003c\u003c \"verbose is set\" \u003c\u003c std::endl;\n}\n\nif (args.at(\"memoryLimit\")-\u003eset) {\n    std::string val = std::any_cast\u003cstd::string\u003e(args.at(\"memoryLimit\")-\u003eGetValue());\n    std::cout \u003c\u003c \"Memory: \" \u003c\u003c val \u003c\u003c std::endl;\n}\n```\n\n## Building\n\nThis project uses CMake, you can convert it to a visual studio project to build it using the CMake-gui program, nothing weird should happen, I've tested it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2004seraph%2Fcyanargparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2004seraph%2Fcyanargparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2004seraph%2Fcyanargparser/lists"}