{"id":21984278,"url":"https://github.com/konvt/pgbar","last_synced_at":"2026-02-05T09:01:33.307Z","repository":{"id":203936412,"uuid":"710711146","full_name":"Konvt/pgbar","owner":"Konvt","description":"A lightweight terminal progress bar for Modern C++.","archived":false,"fork":false,"pushed_at":"2026-02-03T13:48:25.000Z","size":4899,"stargazers_count":29,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-04T03:56:54.589Z","etag":null,"topics":["cli","cli-tool","command-line","cplusplus-library","cpp","cpp11","cpp20","cpp20-modules","cpplibrary","header-only","mit-licence","modern-cpp","progress-bar","progressbar","progressbars","status-bar","template-metaprogramming","thread-safe","tqdm","unicode-support"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Konvt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2023-10-27T09:20:06.000Z","updated_at":"2026-01-24T17:25:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"773bf356-a4e3-4fd6-aaf2-a6525487b2a8","html_url":"https://github.com/Konvt/pgbar","commit_stats":null,"previous_names":["konvt/pgbar"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Konvt/pgbar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konvt%2Fpgbar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konvt%2Fpgbar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konvt%2Fpgbar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konvt%2Fpgbar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Konvt","download_url":"https://codeload.github.com/Konvt/pgbar/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konvt%2Fpgbar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29117916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T05:31:32.482Z","status":"ssl_error","status_checked_at":"2026-02-05T05:31:29.075Z","response_time":65,"last_error":"SSL_read: 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-tool","command-line","cplusplus-library","cpp","cpp11","cpp20","cpp20-modules","cpplibrary","header-only","mit-licence","modern-cpp","progress-bar","progressbar","progressbars","status-bar","template-metaprogramming","thread-safe","tqdm","unicode-support"],"created_at":"2024-11-29T18:08:20.449Z","updated_at":"2026-02-05T09:01:33.296Z","avatar_url":"https://github.com/Konvt.png","language":"C++","readme":"[中文文档见此](docs/README_zh.md)。\n\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/Konvt/pgbar)\n\n## Features\n- **Header-only design**: All functionality contained within a single `.hpp` file in `include/pgbar`.\n- **Low-overhead updates**: Nanosecond level cost per call.[^1]\n- **C++11 \u0026 later compatible**: Supports all standard revisions from C++11 through C++23.\n- **Unicode support**: Parse each string in UTF-8 encoding.\n- **RGB color support**: Customizable progress bar colors.\n- **Thread-safe design**: Can be safely used in multi-threaded environments.\n- **`tqdm`-like interface**: Chainable methods powered by template metaprogramming.\n- **Modern C++ core**: Leverages `constexpr`, RAII, and type traits for zero-cost abstractions.\n\n[^1]: On AMD Ryzen 7 5800H with `-Og` optimization and `Policy::Async` execution strategy, `tick` call overhead measured `≤5ns` in tight loop tests.\n\n## Styles\n### ProgressBar\n```\n{LeftBorder}{Prefix}{Percent}{Starting}{Filler}{Lead}{Remains}{Ending}{Counter}{Speed}{Elapsed}{Countdown}{Postfix}{RightBorder}\n 30.87% | [=========\u003e                    ] |  662933732/2147483647 |  11.92 MHz | 00:00:55 | ~00:02:03\n```\n![progressbar](images/progressbar.gif)\n\n### BlockBar\n```\n{LeftBorder}{Prefix}{Percent}{Starting}{Filler}{Lead}{Remains}{Ending}{Counter}{Speed}{Elapsed}{Countdown}{Postfix}{RightBorder}\n 35.22% | ██████████▋                    |  47275560/134217727 |  16.80 MHz | 00:00:02 | ~00:00:05\n```\n![BlockBar](images/blockbar.gif)\n\n### SpinBar\n```\n{LeftBorder}{Prefix}{Lead}{Percent}{Counter}{Speed}{Elapsed}{Countdown}{Postfix}{RightBorder}\n\\ |  48.64% |  65288807/134217727 |  17.84 MHz | 00:00:03 | ~00:00:03\n```\n![spinbar](images/spinbar.gif)\n\n### SweepBar\n```\n{LeftBorder}{Prefix}{Percent}{Starting}{Filler}{Lead}{Filler}{Ending}{Counter}{Speed}{Elapsed}{Countdown}{Postfix}{RightBorder}\n 39.82% | [-------\u003c=\u003e--------------------] |  53458698/134217727 |  17.89 MHz | 00:00:02 | ~00:00:04\n```\n![sweepbar](images/sweepbar.gif)\n\n### FlowBar\n```\n{LeftBorder}{Prefix}{Percent}{Starting}{Filler}{Lead}{Filler}{Ending}{Counter}{Speed}{Elapsed}{Countdown}{Postfix}{RightBorder}\n 73.93% | [                     ====     ] |   99224978/134217727 |  81.02 MHz | 00:00:01 | ~00:00:00\n```\n![flowbar](images/flowbar.gif)\n\n### MultiBar\n![multibar](images/multibar.gif)\n\n### DynamicBar\n![dynamicbar](images/dynamicbar.gif)\n\n### Usage\n```cpp\n#include \"pgbar/ProgressBar.hpp\"\n\nint main()\n{\n  pgbar::ProgressBar\u003c\u003e bar { pgbar::option::Remains( \"-\" ),\n                             pgbar::option::Filler( \"=\" ),\n                             pgbar::option::Styles( pgbar::config::Line::Entire ),\n                             pgbar::option::RemainsColor( \"#A52A2A\" ),\n                             pgbar::option::FillerColor( 0x0099FF ),\n                             pgbar::option::InfoColor( pgbar::color::Yellow ),\n                             pgbar::option::Tasks( 100 ) };\n\n  for ( auto _ = 0; _ \u003c 100; ++_ )\n    bar.tick();\n}\n```\n\nFor more examples, see [QuickStart.md](docs/QuickStart.md) and [demo/](demo/).\n\n## FAQ\n### How to build?\n#### Header-only\nYou can copy `include/pgbar` to the inclusion path of the project, and then directly include the corresponding header file within the source file.\n#### C++20 Module\nIf you are using a compiler that already supports the `module` functionality, you can use the `*.ixx` module interface files under `include/` and import it in your project.\n\n\u003e The `include/` contains a compilation `Makefile` for `gcc 15.1`.\n\n`pgbar` supports the following forms of `import`:\n\n```cpp\nimport pgbar.Core;        // Only import core functions, such as exception types, etc\nimport pgbar.ProgressBar; // Import as needed. All progress bar modules will automatically import pgbar.Core\nimport pgbar.MultiBar;    // The functions imported between different modules are orthogonal to each other\nimport pgbar;             // Import all functions at once\n```\n\nWhen using it officially, be sure to `import std` in the code file at the same time; otherwise, strange compilation errors will occur as of now.\n#### Release package\nDownload the release package (zip file) from [Releases](https://github.com/Konvt/pgbar/releases).\n\nUnzip the compressed package and add the following code at the corresponding position in the `CMakeLists.txt` file of the project:\n\n```cmake\n# If the decompressed files are placed in a path that CMake can directly search, the following line is not needed.\nlist(APPEND CMAKE_PREFIX_PATH \"path/to/package/pgbar/lib/cmake\")\nfind_package(pgbar CONFIG REQUIRED)\n# ...\nadd_executable(TargetName ${SOURCES})\ntarget_link_libraries(TargetName PRIVATE pgbar)\n```\n#### Submodule\nUse `git` to introduce `pgbar` as a sub-module into your project directory:\n\n```bash\ngit submodule add https://github.com/Konvt/pgbar path/to/pgbar\ngit submodule update --init --recursive\n```\n\nThen, add the following lines to your `CMakeLists.txt`:\n\n```cmake\nadd_subdirectory(path/to/pgbar)\n# ...\nadd_executable(TargetName ${SOURCES})\ntarget_link_libraries(TargetName PRIVATE pgbar)\n```\n\n\u003e Note: The `main` branch of `pgbar` is the stable version. If you need the latest updates, you can switch to the `nightly` branch:\n\n```bash\ncd path/to/pgbar\ngit checkout nightly\n```\n\nThe sample files under `demo/` can be compiled using the following commands.\n\n```bash\ncmake -S . -DPGBAR_BUILD_DEMO=ON -B build\ncmake --build build --target demo\n# Or use demo_{filename} to compile the specified file under demo/\n```\n\nOr compile directly using the `make` command in the `demo/` folder.\n\n```bash\nmake all\n# Or use {filename} to compile the specified file under demo/\n```\n#### Installation\nExecute the following commands to install `pgbar` to the default directory of the system.\n\n```bash\ncmake -S . -DPGBAR_INSTALL=ON -B build\n# Or install it to the specified directory:\n# cmake -S . -DPGBAR_INSTALL=ON -DCMAKE_INSTALL_PREFIX=/usr -B build\ncmake --install build\n# Equivalent instructions can be:\n# cmake --build build --target install\n```\n\nWhen uninstalling, it needs to rely on the cache files generated during installation. If the cache files has been removed, the installation command generation can be executed again.\n\nExecute the following commands to remove `pgbar` from the system.\n\n```bash\ncmake --build build --target uninstall\n```\n\n### Does updating the progress bar slow down the program?\nNo, as mentioned in the [Features](#features) section, updating the progress bar has *essentially* zero overhead.\n\nWith `O2/O3` optimizations enabled, the performance overhead of the second iteration in the code below will *approach* that of the first iteration.[^2]\n\n[^2]: In practice, the overhead of updating the progress bar only adds the overload of calling jumps and branches a few more times.\n\n```cpp\n#include \"pgbar/pgbar.hpp\"\n\nint main()\n{\n  std::size_t count = 0;\n  for ( std::size_t _ = 0; _ \u003c 2147483647; ++_ )\n    ++count;\n\n  pgbar::ProgressBar\u003c\u003e bar { pgbar::option::Tasks( 2147483647 ) };\n  for ( std::size_t _ = 0; _ \u003c 2147483647; ++_ )\n    bar.tick();\n}\n```\n\nHowever, the smoothness of the display will depend on the single-core performance of your processor.\n### Is it compatible with Windows/Linux?\nAbsolutely. I designed this library to work seamlessly on both systems, providing a unified visualization of iteration progress.\n\nBtw, it should be noted that if it is on the Windows platform, then `pgbar` will depend on the `Windows.h` header file; Moreover, `NOMINMAX` will be defined to disable the `min` and `max` macros.\n### Does it support Unicode?\nAs pointed out at the beginning, there is no problem.\n\nAlthough only UTF-8 encoded strings are currently supported, using any non-UTF-8 encoded string will result in an exception.\n\nIf you are using the C++20, `pgbar`'s functions also support `u8string`.\n\n![unicode](images/unicode.gif)\n\n## License\nThis project is licensed under the [MIT](LICENSE) license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonvt%2Fpgbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonvt%2Fpgbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonvt%2Fpgbar/lists"}