docs: Add README
While here, clean up and s/zb64/b64/g
This commit is contained in:
parent
a73152d972
commit
45523d1292
4 changed files with 60 additions and 4 deletions
56
README.md
Normal file
56
README.md
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
# b64
|
||||||
|
|
||||||
|
Is a tool I created to
|
||||||
|
* Quickly encode and decode base64
|
||||||
|
* Learn a bit of Zig
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
```
|
||||||
|
Usage: b64 [-e] [-d] <string>
|
||||||
|
|
||||||
|
-h, --help
|
||||||
|
Display this help and exit.
|
||||||
|
|
||||||
|
-d, --decode
|
||||||
|
Decode base64 to string.
|
||||||
|
|
||||||
|
-e, --encode
|
||||||
|
Encode string to base64.
|
||||||
|
|
||||||
|
-v, --version
|
||||||
|
Display version.
|
||||||
|
|
||||||
|
<str>
|
||||||
|
String to encode or decode.
|
||||||
|
```
|
||||||
|
### Encoding
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ b64 -e "encode this string to base64"
|
||||||
|
ZW5jb2RlIHRoaXMgc3RyaW5nIHRvIGJhc2U2NA==
|
||||||
|
|
||||||
|
# From stdin
|
||||||
|
$ echo -n "encode this string to base64" | b64 -e
|
||||||
|
ZW5jb2RlIHRoaXMgc3RyaW5nIHRvIGJhc2U2NA==
|
||||||
|
$
|
||||||
|
```
|
||||||
|
|
||||||
|
### Decoding
|
||||||
|
```shell
|
||||||
|
$ b64 -d ZW5jb2RlIHRoaXMgc3RyaW5nIHRvIGJhc2U2NA==
|
||||||
|
encode this string to base64
|
||||||
|
|
||||||
|
# From stdin
|
||||||
|
$ echo -n "ZW5jb2RlIHRoaXMgc3RyaW5nIHRvIGJhc2U2NA==" | b64 -d
|
||||||
|
encode this string to base64
|
||||||
|
$
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ git clone https://git.kcbark.net/zig/b64.git && cd b64
|
||||||
|
$ zig build -Doptimize=ReleaseFast
|
||||||
|
$ cp zig-out/bin/b64 ~/.local/bin
|
||||||
|
```
|
|
@ -21,7 +21,7 @@ pub fn build(b: *std.Build) void {
|
||||||
var opt = b.addOptions();
|
var opt = b.addOptions();
|
||||||
opt.addOption([]const u8, "version", "0.0.1");
|
opt.addOption([]const u8, "version", "0.0.1");
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "zb64",
|
.name = "b64",
|
||||||
// In this case the main source file is merely a path, however, in more
|
// In this case the main source file is merely a path, however, in more
|
||||||
// complicated build scripts, this could be a generated file.
|
// complicated build scripts, this could be a generated file.
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
.root_source_file = .{ .path = "src/main.zig" },
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.{
|
.{
|
||||||
.name = "zb64",
|
.name = "b64",
|
||||||
.version = "0.0.1",
|
.version = "0.0.1",
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.clap = .{
|
.clap = .{
|
||||||
|
|
|
@ -109,11 +109,11 @@ pub fn main() !void {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() void {
|
fn usage() void {
|
||||||
std.debug.print("Usage: zb64 [-e] [-d] <string>\n\n", .{});
|
std.debug.print("Usage: b64 [-e] [-d] <string>\n\n", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn version() void {
|
fn version() void {
|
||||||
std.debug.print("zb64 - {s}\n", .{build_info.version});
|
std.debug.print("b64 - {s}\n", .{build_info.version});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_from_stream(allocator: std.mem.Allocator, stream: std.fs.File) !std.ArrayList(u8) {
|
fn read_from_stream(allocator: std.mem.Allocator, stream: std.fs.File) !std.ArrayList(u8) {
|
||||||
|
|
Loading…
Reference in a new issue