A lightweight, customizable command-line progress bar implementation in C++. This library provides a simple way to add visual progress indicators to your command-line applications with minimal setup.
- Customizable progress bar appearance
- Support for custom messages
- Configurable update intervals
- Adjustable bar width
- Error handling and input validation
- Cross-platform compatibility
- Header-only implementation
Loading... [45% ] ##################
Processing [80% ] ================================
- C++11 or later
- Standard Template Library (STL)
- CMake 3.10 or later (for building with CMake)
Simply copy progress_bar.hpp
to your project and include it:
#include "progress_bar.hpp"
git clone https://github.com/yourusername/cpp-progress-bar.git
cd cpp-progress-bar
# Build
g++ -std=c++11 main.cpp -o progress_bar
# Run
./progress_bar
mkdir build
cd build
cmake ..
make
./progress_bar
#include <iostream>
#include "progress_bar.hpp"
int main() {
// Simple progress bar with default settings
show_progress_bar(std::cout, 100, "Loading...");
return 0;
}
// Custom width and fill character
show_progress_bar(std::cout, 50, "Processing", 50, '#');
// Custom output stream
show_progress_bar(std::clog, 100, "Downloading", 70, '=');
void show_progress_bar(
std::ostream& os, // Output stream
int update_interval_ms, // Update interval in milliseconds
const std::string& message, // Display message
size_t bar_width = 70, // Total bar width (optional)
char fill_char = '*' // Fill character (optional)
);
Parameter | Type | Description | Default |
---|---|---|---|
os | std::ostream& | Output stream for the progress bar | Required |
update_interval_ms | int | Time between updates in milliseconds | Required |
message | const std::string& | Message to display before the bar | Required |
bar_width | size_t | Total width of the progress bar | 70 |
fill_char | char | Character used to fill the bar | '*' |
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
- Use consistent indentation (4 spaces)
- Follow C++ best practices
- Add comments for complex logic
- Include unit tests for new features
- Update documentation as needed
- Initial release
- Basic progress bar functionality
- Customizable appearance
- Error handling
- Cross-platform support