{"id":46172109,"url":"https://github.com/gknowles/dimcli","last_synced_at":"2026-03-02T16:38:33.945Z","repository":{"id":44801179,"uuid":"70302775","full_name":"gknowles/dimcli","owner":"gknowles","description":"C++ Command Line Parser Toolkit","archived":false,"fork":false,"pushed_at":"2026-02-04T21:46:29.000Z","size":5408,"stargazers_count":38,"open_issues_count":4,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-02-04T23:45:38.840Z","etag":null,"topics":["cli","cli-args","command-line","getopt","subcommands"],"latest_commit_sha":null,"homepage":"https://gknowles.github.io/dimcli","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/gknowles.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-10-08T04:03:37.000Z","updated_at":"2025-11-21T05:58:59.000Z","dependencies_parsed_at":"2023-02-16T04:01:03.062Z","dependency_job_id":"4e600433-c142-4773-8255-5acdf758bb6c","html_url":"https://github.com/gknowles/dimcli","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/gknowles/dimcli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gknowles%2Fdimcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gknowles%2Fdimcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gknowles%2Fdimcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gknowles%2Fdimcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gknowles","download_url":"https://codeload.github.com/gknowles/dimcli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gknowles%2Fdimcli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30009928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T15:15:59.058Z","status":"ssl_error","status_checked_at":"2026-03-02T15:15:58.758Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cli","cli-args","command-line","getopt","subcommands"],"created_at":"2026-03-02T16:38:33.125Z","updated_at":"2026-03-02T16:38:33.938Z","avatar_url":"https://github.com/gknowles.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿\u003c!--\nCopyright Glen Knowles 2016 - 2025.\nDistributed under the Boost Software License, Version 1.0.\n--\u003e\n\n# dimcli\n\n| Branch | MSVC 2015\u0026#8209;2017 \u003cbr\u003e CLANG 6, 10\u0026#8209;12 \u003cbr\u003e GCC 7\u0026#8209;9 | MSVC 2019\u0026#8209;2022 \u003cbr\u003e CLANG 13\u0026#8209;21 \u003cbr\u003e GCC 10\u0026#8209;14 | Test Coverage |\n| :----: | :-----------------------------------: | :--------------------------------------: | :-----------: |\n| master | [![Build Status][av-image-master]][av-link-master] | [![Build Status][gh-image-master]][gh-link-master] | [![Coverage][cc-image-master]][cc-link-master] |\n| dev    | [![Build Status][av-image-dev]][av-link-dev] | [![Build Status][gh-image-dev]][gh-link-dev] | [![Coverage][cc-image-dev]][cc-link-dev] |\n\n[av-image-master]: https://ci.appveyor.com/api/projects/status/02i9uq9asqlb6opy/branch/master?svg=true \"AppVeyor\"\n[av-link-master]: https://ci.appveyor.com/project/gknowles/dimcli/branch/master\n[gh-image-master]: https://github.com/gknowles/dimcli/actions/workflows/github-build-all.yml/badge.svg?query=branch%3Amaster \"GitHub\"\n[gh-link-master]: https://github.com/gknowles/dimcli/actions/workflows/github-build-all.yml?query=branch%3Amaster\n[cc-image-master]: https://codecov.io/gh/gknowles/dimcli/branch/master/graph/badge.svg \"Codecov\"\n[cc-link-master]: https://app.codecov.io/gh/gknowles/dimcli/tree/master\n\n[av-image-dev]: https://ci.appveyor.com/api/projects/status/02i9uq9asqlb6opy/branch/dev?svg=true \"AppVeyor\"\n[av-link-dev]: https://ci.appveyor.com/project/gknowles/dimcli/branch/dev\n[gh-image-dev]: https://github.com/gknowles/dimcli/actions/workflows/github-build-all.yml/badge.svg?query=branch%3Adev \"GitHub\"\n[gh-link-dev]: https://github.com/gknowles/dimcli/actions/workflows/github-build-all.yml?query=branch%3Adev\n[cc-image-dev]: https://codecov.io/gh/gknowles/dimcli/branch/dev/graph/badge.svg \"Codecov\"\n[cc-link-dev]: https://app.codecov.io/gh/gknowles/dimcli/tree/dev\n\n\nC++ command line parser toolkit for kids of all ages.\n\n- GNU style command lines (-o, --output=FILE, etc.)\n- Parses to any supplied (or implicitly created) variable whose type is:\n  - Default constructible\n  - Copyable\n  - Either assignable or constructible from string, has an istream extraction\n    operator, or has a specialization of Cli\u0026#58;:Convert::fromString\u0026lt;T\u003e().\n- Render help text\n- Option definitions can be scattered across multiple files.\n- Git style subcommands.\n- Response files (requires `\u003cfilesystem\u003e` support).\n- Convert argv to/from command line with Windows, Posix, or GNU semantics.\n- Word wrap arbitrary paragraphs and simple text tables for console output.\n- Works whether or not exceptions and RTTI are disabled.\n- Distributed under the Boost Software License, Version 1.0.\n\n## Sample Usage\n\nCheck out the complete [documentation](https://gknowles.github.io/dimcli/),\ncontains many examples, and the quick\n[reference](https://gknowles.github.io/dimcli/reference.html).\n\n~~~ C++\n#include \"dimcli/cli.h\"\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\nusing namespace std;\n\nint main(int argc, char * argv[]) {\n    Dim::Cli cli;\n\n    // Define option that populates an existing variable.\n    int count;\n    cli.opt(\u0026count, \"c n count\", 1).desc(\"Times to say hello.\");\n\n    // Or, define option without referencing an existing variable. The variable\n    // to populate is then implicitly allocated and the returned object is used\n    // like a smart pointer to access it.\n    auto \u0026 name = cli.opt\u003cstring\u003e(\"name\", \"Unknown\")\n        .desc(\"Who to greet.\");\n\n    // Parse command line.\n    if (!cli.parse(argc, argv))\n        return cli.printError(cerr);\n\n    // Access the options.\n    if (!name)\n        cout \u003c\u003c \"Greeting the unknown.\" \u003c\u003c endl;\n    for (int i = 0; i \u003c count; ++i)\n        cout \u003c\u003c \"Hello \" \u003c\u003c *name \u003c\u003c \"!\" \u003c\u003c endl;\n    return 0;\n}\n~~~\n\nWhat it does when run:\n\n~~~ console\n$ a.out -x\nError: Unknown option: -x\n$ a.out --help\nUsage: a.out [OPTIONS]\n\nOptions:\n  -c, -n, --count=NUM  Times to say hello. (default: 1)\n  --name=STRING        Who to greet. (default: Unknown)\n\n  --help               Show this message and exit.\n$ a.out --count=2\nGreeting the unknown.\nHello Unknown!\nHello Unknown!\n$ a.out --name John\nHello John!\n~~~\n\n## Include in Your Project\n### Copy source directly into your project\nAll you need is:\n- libs/dimcli/cli.h\n- libs/dimcli/cli.cpp\n\n### Using [vcpkg](https://github.com/Microsoft/vcpkg)\n- vcpkg install dimcli\n\n### Using cmake\nGet the latest dimcli [release](https://github.com/gknowles/dimcli/releases).\n\nBuild it (this example uses Visual C++ 2022 to install a 64-bit build to\nc:\\dimcli on a windows machine):\n- md build \u0026 cd build\n- cmake .. -DCMAKE_INSTALL_PREFIX=c:\\dimcli -G \"Visual Studio 17 2022 Win64\"\n- cmake --build .\n- ctest -C Debug\n- cmake --build . --target install\n\n## Working on the dimcli Project\n- Prerequisites\n  - install cmake \u003e= 3.10\n  - install Visual Studio \u003e= 2015\n    - include the \"Github Extension for Visual Studio\" (if you care)\n    - include git\n- Make the library (assuming VS 2022)\n  - git clone https://github.com/gknowles/dimcli.git\n  - cd dimcli\n  - git submodule update --init\n  - md build \u0026 cd build\n  - cmake .. -G \"Visual Studio 17 2022 Win64\"\n  - cmake --build .\n- Test\n  - ctest -C Debug\n- Visual Studio\n  - open dimcli\\build\\dimcli.sln\n\n## Random Thoughts\n### Why not a single header file?\n\n- On large projects with many binaries (tests, utilities, etc) it's good for\n  compile times to move as much stuff out of the headers as you easily can.\n- Inflicting \u003cWindows.h\u003e (and to a much lesser extent \u003ctermios.h\u003e \u0026 \u003cunistd.h\u003e)\n  on all clients seems a bridge too far.\n\n### Sources of inspiration:\n\n- LLVM CommandLine module\n- click - Python command line interface creation kit\n- My own bad experiences\n\n### Things that were harder than expected:\n\n- Parsing command lines with bash style quoting\n- Response files - because of the need to transcode UTF-16 on Windows\n- Password prompting - there's no standard way to disable console echo :(\n- Build system - you can do a lot with CMake, but it's not always easy\n\n### Build hosting services:\n\nNow almost a decade later I can say that the automated testing enabled by build\nhosting services is wonderful. But they have also been the biggest ongoing\nannoyance, pain, and frustration. All stemming from the desire to test under a\nwide range of compilers and not just the newest ones. It's gone from Travis CI\nto AppVeyor to GitHub Workflow to Circle CI to a mix, where the changes are all\nbecause of a lack of support, performance, or dropping support. Perhaps it's\ndifferent with the paid tiers, but they don't make sense for a small volunteer\nproject.\n\n### Other interesting C++ command line parsers:\n\n- [program_options](http://www.boost.org/doc/libs/release/libs/program_options/)\n  \\- from boost\n- [gflags](https://gflags.github.io/gflags/) - from google\n- [tclap](http://tclap.sourceforge.net) - header only\n- [args](https://github.com/Taywee/args) - single header\n- [cxxopts](https://github.com/jarro2783/cxxopts) - single header\n- [CLI11](https://github.com/CLIUtils/CLI11) - header only\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgknowles%2Fdimcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgknowles%2Fdimcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgknowles%2Fdimcli/lists"}