anybit is a Zig library that provides various utilities for building modern CLI applications, including ANSI text formatting, argument parsing, progress bars, and logging.
This project is primarily a learning journey to improve Zig skills and become a better developer. The goal is to write clear, efficient, and maintainable code without overengineering, making it a useful resource for others who want to learn Zig as well. Contributions are welcome, especially if they help simplify and enhance the library while keeping it approachable for newcomers.
This library is fully inspired by kleur, a minimal and fast ANSI color formatting library for JavaScript.
- Lightweight: Minimal dependencies, optimized for performance.
- ANSI Styling: Easily add colors and styles to terminal output.
- Loading Bars: Display smooth loading indicators.
- Argument Parsing: Simple and efficient command-line argument handling.
Clone the repository and use zig build:
# Clone the repository
git clone https://github.com/mkv27/anybit.git
cd anybit
# Build the library
zig buildIn your Zig project, import anybit as a module:
const anybit = @import("anybit");
const ansi = anybit.ansi;const std = @import("std");
const ansi = @import("anybit").ansi;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
defer _ = gpa.deinit();
const styledText = try ansi.format(allocator, "Hello, Zig!", &.{ ansi.AnsiStyle.Red, ansi.AnsiStyle.Bold });
defer allocator.free(styledText);
std.debug.print("{s}\n", .{styledText});
}zig build runTo run the unit tests, use:
zig build testanybit/
│── docs/
│── src/
│ ├── root.zig # Library entry point
│ ├── ansi.zig # ANSI styling utilities
│ ├── args.zig # Argument parsing (future)
│ ├── progress.zig # Progress bar utilities (future)
│── tests/
│ ├── ansi_test.zig # Tests for ANSI module
│── build.zig # Zig build system
│── README.md # Documentation
Contributions are welcome! Feel free to submit issues and pull requests.
This project is licensed under the MIT License.