{"id":15047540,"url":"https://github.com/bfgroup/lyra","last_synced_at":"2025-04-14T20:57:15.959Z","repository":{"id":41972683,"uuid":"140041506","full_name":"bfgroup/Lyra","owner":"bfgroup","description":"A simple to use, composable, command line parser for C++ 11 and beyond","archived":false,"fork":false,"pushed_at":"2025-04-03T02:49:45.000Z","size":2194,"stargazers_count":509,"open_issues_count":15,"forks_count":64,"subscribers_count":12,"default_branch":"develop","last_synced_at":"2025-04-07T16:12:02.913Z","etag":null,"topics":["argument-parser","argument-parsing","arguments","cli","cmdline-parser","command-line","command-line-parser","cpp","cpp11","cpp14","cpp17","cpp20","header-only","option-parser","options","options-parsing","parameters","parser"],"latest_commit_sha":null,"homepage":"https://bfgroup.github.io/Lyra/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bfgroup.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":"CONTRIBUTING.adoc","funding":".github/FUNDING.yml","license":"LICENSE.txt","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},"funding":{"github":["grafikrobot"]}},"created_at":"2018-07-07T00:48:42.000Z","updated_at":"2025-04-04T12:16:25.000Z","dependencies_parsed_at":"2024-01-31T09:02:22.245Z","dependency_job_id":"795ab96b-3329-474d-acbc-e761660a41a9","html_url":"https://github.com/bfgroup/Lyra","commit_stats":{"total_commits":449,"total_committers":25,"mean_commits":17.96,"dds":0.3184855233853007,"last_synced_commit":"673539348ab05e67fca7477806b9f00bd48734b2"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfgroup%2FLyra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfgroup%2FLyra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfgroup%2FLyra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfgroup%2FLyra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bfgroup","download_url":"https://codeload.github.com/bfgroup/Lyra/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248961186,"owners_count":21189991,"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-parser","argument-parsing","arguments","cli","cmdline-parser","command-line","command-line-parser","cpp","cpp11","cpp14","cpp17","cpp20","header-only","option-parser","options","options-parsing","parameters","parser"],"created_at":"2024-09-24T20:59:56.443Z","updated_at":"2025-04-14T20:57:15.931Z","avatar_url":"https://github.com/bfgroup.png","language":"C++","readme":"= Lyra\n\n// tag::intro[]\n\n[.tagline]\nA simple to use, composing, header only, command line arguments parser for C++ 11 and beyond.\n\n[horizontal.shields]\nObtain::\nimage:https://img.shields.io/github/downloads/bfgroup/Lyra/total.svg?label=GitHub[GitHub All Releases, link=\"https://github.com/bfgroup/Lyra/releases\"]\nimage:https://img.shields.io/badge/package-Conan-blue[Conan Center, link=\"https://conan.io/center/lyra\"]\nLicense:: image:https://img.shields.io/badge/license-BSL%201.0-blue.svg[\"Boost Software License 1.0\", link=\"LICENSE.txt\"]\nStandards::\nimage:https://img.shields.io/badge/standard-C%2B%2B%2011-blue.svg?logo=C%2B%2B[\"C\\+\\+ 11\", link=\"https://isocpp.org/\"]\nimage:https://img.shields.io/badge/standard-C%2B%2B%2014-blue.svg?logo=C%2B%2B[\"C\\+\\+ 14\", link=\"https://isocpp.org/\"]\nimage:https://img.shields.io/badge/standard-C%2B%2B%2017-blue.svg?logo=C%2B%2B[\"C\\+\\+ 17\", link=\"https://isocpp.org/\"]\nimage:https://img.shields.io/badge/standard-C%2B%2B%2020-blue.svg?logo=C%2B%2B[\"C\\+\\+ 20\", link=\"https://isocpp.org/\"]\nimage:https://img.shields.io/badge/standard-C%2B%2B%2023-blue.svg?logo=C%2B%2B[\"C\\+\\+ 23\", link=\"https://isocpp.org/\"]\nStats:: image:https://img.shields.io/github/languages/code-size/bfgroup/Lyra.svg[GitHub code size in bytes, link=\"https://github.com/bfgroup/Lyra\"]\nimage:https://img.shields.io/github/issues/bfgroup/Lyra.svg[GitHub issues, link=\"https://github.com/bfgroup/Lyra/issues\"]\nimage:https://img.shields.io/github/stars/bfgroup/Lyra.svg?label=%E2%98%85[GitHub stars, link=\"https://github.com/bfgroup/Lyra/stargazers\"]\nTests:: image:https://img.shields.io/azure-devops/build/bfgroup/6b664745-b518-4d13-8e46-807d74231e73/2/release?label=release\u0026logo=azuredevops[\"Azure DevOps\", link=\"https://dev.azure.com/bfgroup/Lyra\"]\nimage:https://img.shields.io/azure-devops/build/bfgroup/6b664745-b518-4d13-8e46-807d74231e73/2/develop?label=develop\u0026logo=azuredevops[\"Azure DevOps\", link=\"https://dev.azure.com/bfgroup/Lyra\"]\nimage:https://img.shields.io/appveyor/build/bfgroup/lyra/release?label=release\u0026logo=appveyor[\"AppVeyor\", link=\"https://ci.appveyor.com/project/bfgroup/lyra\"]\nimage:https://img.shields.io/appveyor/build/bfgroup/lyra/develop?label=develop\u0026logo=appveyor[\"AppVeyor\", link=\"https://ci.appveyor.com/project/bfgroup/lyra\"]\n\n// end::intro[]\n\n== License\n\n// tag::license[]\n\nDistributed under the Boost Software License, Version 1.0. (See accompanying\nfile LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n// end::license[]\n\n== Features\n\n// tag::features[]\n\n* Header only with no external dependencies (except the `std` library).\n* Define your interface once to get parsing, type conversions and usage\n  strings with no redundancy.\n* Composing. Each `opt` or `arg` is an independent parser. Combine these to\n  produce a composite parser -- this can be done in stages across multiple\n  function calls -- or even projects.\n* Bind parsers directly to variables that will receive the results of the parse\n  -- no intermediate dictionaries to worry about.\n* Or can also bind parsers to lambdas for more custom handling.\n* Deduces types from bound variables or lambdas and performs type conversions\n  (via `ostream \u003c\u003c`), with error handling, behind the scenes.\n* Bind parsers to vectors for args that can have multiple values.\n* Uses result types for error propagation, rather than exceptions (doesn't yet\n  build with exceptions disabled, but that will be coming later)\n* Models POSIX standards for short and long opt behavior.\n* Customizable option syntax.\n* Specify cardinality of `arg`-s from one to many.\n* Limit option values to a specified set of values.\n* Recursive argument groups with callback for detection. This allows for\n  easy and generic sub-command specifications.\n\n// end::features[]\n\n== Using\n\n// tag::using[]\n\nTo use, just `#include \u003clyra/lyra.hpp\u003e`\n\nA parser for a single option can be created like this:\n\n[source,cpp]\n----\nint width = 0;\nauto cli = lyra::cli()\n    | lyra::opt( width, \"width\" )\n        [\"-w\"][\"--width\"]\n        (\"How wide should it be?\");\n----\n\nYou can use this parser directly like this:\n\n[source,cpp]\n----\nauto result = cli.parse( { argc, argv } );\nif ( !result )\n{\n\tstd::cerr \u003c\u003c \"Error in command line: \" \u003c\u003c result.message() \u003c\u003c std::endl;\n\texit(1);\n}\n\n// Everything was ok, width will have a value if supplied on command line.\n----\n\nNote that exceptions are not used for error handling.\n\nYou can combine parsers by composing with `|`, like this:\n\n[source,cpp]\n----\nint width = 0;\nstd::string name;\nbool doIt = false;\nstd::string command;\nauto cli\n    = lyra::opt( width, \"width\" )\n        [\"-w\"][\"--width\"]\n        (\"How wide should it be?\")\n    | lyra::opt( name, \"name\" )\n        [\"-n\"][\"--name\"]\n        (\"By what name should I be known\")\n    | lyra::opt( doIt )\n        [\"-d\"][\"--doit\"]\n        (\"Do the thing\" )\n    | lyra::arg( command, \"command\" )\n        (\"which command to run\");\n----\n\n`opt` specifies options that start with a short dash (`-`) or long dash (`--`).\nOptions can be argument taking (such as `-w 42`), in which case\nthe `opt` takes a second argument -- a hint, or they are pure flags (such as\n`-d`), in which case the `opt` has only one argument -- which must be a boolean.\nThe option names are provided in one or more sets of square brackets, and a\ndescription string can be provided in parentheses. The first argument to an\n`opt` is any variable, local, global member, of any type that can be converted\nfrom a string using `std::ostream`.\n\n`arg` specifies arguments that are not tied to options, and so have no square\nbracket names. They otherwise work just like `opt`.\n\nA usage string can be obtained by inserting the parser into\na stream. The usage string is built from the information supplied.\n\nAs a convenience, the standard help options (`-h`, `--help` and `-?`) can be\nspecified using the `help` parser, which just takes a boolean to bind to.\n\n// end::using[]\n\n== More\n\nThere is a single-header version that is generated from the source files.\nYou can find it at `data/single_include/lyra/lyra.hpp`. Some caveats for it:\n\n* It's not the preferred method of using the library.\n* It's not thoroughly tested.\n* It's intended for use cases like Compiler Explorer. Where it allows for\n    immediate experimentation.\n* Support for it will not be a priority.\n* Hence prefer to use the regular multi-file sources in your projects.\n\nFor more information and documentation see the\nlink:https://bfgroup.github.io/Lyra/[web site].\n","funding_links":["https://github.com/sponsors/grafikrobot"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfgroup%2Flyra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbfgroup%2Flyra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfgroup%2Flyra/lists"}