Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seqan/sharg-parser
The modern argument parser for c++ tools
https://github.com/seqan/sharg-parser
argument-parsing command-line-parser cpp cpp20 modern-cpp
Last synced: about 2 months ago
JSON representation
The modern argument parser for c++ tools
- Host: GitHub
- URL: https://github.com/seqan/sharg-parser
- Owner: seqan
- License: other
- Created: 2021-11-18T11:45:20.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-28T14:53:16.000Z (4 months ago)
- Last Synced: 2024-08-28T16:11:27.124Z (4 months ago)
- Topics: argument-parsing, command-line-parser, cpp, cpp20, modern-cpp
- Language: C++
- Homepage: https://docs.seqan.de/sharg
- Size: 1.48 MB
- Stars: 10
- Watchers: 6
- Forks: 7
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# [![sharg_logo][sharg_logo_link]][sharg_link] Sharg -- hungrily eating away your arguments
[![build status][ci_badge]][github_actions]
[![codecov][codecov_badge]][codecov_link]
[![license][copy_badge]][copy_link]
[![platforms][api_badge]][api_link]
[![twitter][twitter_badge]][twitter_link][sharg_logo_link]: ./test/documentation/sharg_logo.svg "Open documentation"
[sharg_link]: https://docs.seqan.de/sharg.html
[ci_badge]: https://img.shields.io/github/actions/workflow/status/seqan/sharg-parser/ci_linux.yml?branch=main&style=flat&logo=github&label=Sharg%20CI "Open GitHub actions page"
[github_actions]: https://github.com/seqan/sharg-parser/actions?query=branch%3Amain
[codecov_badge]: https://codecov.io/gh/seqan/sharg-parser/branch/main/graph/badge.svg?token=KIdo8b91jb "Open Codecov page"
[codecov_link]: https://codecov.io/gh/seqan/sharg-parser
[copy_badge]: https://img.shields.io/badge/license-BSD-green.svg "Open Copyright page"
[copy_link]: https://docs.seqan.de/sharg/main_user/about_copyright.html
[api_badge]: https://img.shields.io/badge/platform-linux%20%7C%20bsd%20%7C%20osx-informational.svg "Read more about our API"
[api_link]: https://docs.seqan.de/sharg/main_user/about_api.html
[twitter_badge]: https://img.shields.io/twitter/follow/SeqAnLib.svg?label=follow&style=social "Follow us on Twitter"
[twitter_link]: https://twitter.com/seqanlib
The Sharg parser offers a neat and easy-to-use header-only library for argument parsing in C++. With Sharg, your command
line interface can be customized to your specific needs and validated in a single line. Furthermore, the library provides
helpful templates and makes even subcommands feel effortless. For more information, details, and a tutorial on how to
use our features, please see our [online documentation](https://docs.seqan.de/sharg/main_user/index.html).If you are working in the field of sequence analysis, we recommend using the
[SeqAn3 library](https://github.com/seqan/seqan3), which offers a wide range of bioinformatics-related C++ features.## Sneak Peek:
An application with one option parsing an integer from the command line can be written in only 5 lines of code:
```cpp
#includeint main(int argc, char ** argv)
{
int val{};sharg::parser parser{"Eat-Me-App", argc, argv};
parser.add_subsection("Eating Numbers");
parser.add_option(val, sharg::config{.short_id = 'i', .long_id = "int", .description = "Desc."});
parser.parse();return 0;
}
```Done. `val` is automatically filled with the value provided by `-i` or `--int`.
You also have a pretty help page and many more features:
```out
user$ ./Eat-Me-App -h
Eat-Me-App
==========OPTIONS
Eating Numbers
-i, --int (signed 32 bit integer)
Desc. Default: 0Common options
-h, --help
Prints the help page.
-hh, --advanced-help
Prints the help page including advanced options.
--version
Prints the version information.
--copyright
Prints the copyright/license information.
--export-help (std::string)
Export the help page information. Value must be one of [html, man,
ctd, cwl].
--version-check (bool)
Whether to check for the newest app version. Default: trueVERSION
Last update:
Eat-Me-App version:
Sharg version: 1.1.2-rc.1
```## Dependencies
| | requirement | version | comment |
|-------------------|-----------------------------------------------------------|----------|---------------------------------------------|
|**compiler** | [GCC](https://gcc.gnu.org) | ≥ 11 | |
|**compiler** | [Clang](https://clang.llvm.org/) | ≥ 17 | |
|**build system** | [CMake](https://cmake.org) | ≥ 3.16 | optional, but recommended |
|**optional libs** | [TDL](https://github.com/deNBI-cibi/tool_description_lib) | ≥ 1.0.0 | required for CWL and CTD export |