From 105962593321522f29005f004ebda4325bf1d5dc Mon Sep 17 00:00:00 2001 From: Evan Burkey Date: Thu, 7 Nov 2024 09:42:51 -0800 Subject: [PATCH] help and README --- README.md | 18 ++++++++++++++---- src/main.zig | 9 +++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e21980e..bfd80ef 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,19 @@ A base64 encoder & decoder in Zig ## Usage ```shell -# Encoding -echo -n "hello" | baze64 +# Print help -# Decoding -echo -n "aGVsbG8=" | baze64 +# Encoding +> baze64 "hello" + +# Decoding with -D or -d +> baze64 -D "aGVsbG8=" + +# Print help +> baze64 -H +Usage: baze64 {-d/-D} {-h/-H} input +With no arguments, encodes input into a base64 string +Args: + -d -D: decodes a base64 string + -h -H: print this help ``` \ No newline at end of file diff --git a/src/main.zig b/src/main.zig index e621fef..2763313 100644 --- a/src/main.zig +++ b/src/main.zig @@ -4,9 +4,11 @@ const stdout = std.io.getStdOut().writer(); const Base64 = @import("base64.zig"); const usageText = - \\Usage: baze64 {-d/-D} input + \\Usage: baze64 {-d/-D} {-h/-H} input + \\With no arguments, encodes input into a base64 string \\Args: - \\ -d -D: decode instead of encode + \\ -d -D: decodes a base64 string + \\ -h -H: print this help ; @@ -33,6 +35,9 @@ pub fn main() !void { if (std.mem.eql(u8, arg, "-d") or std.mem.eql(u8, arg, "-D")) { decodeSwitch = true; + } else if (std.mem.eql(u8, arg, "-h") or std.mem.eql(u8, arg, "-H")) { + try stdout.print("{s}\n", .{usageText}); + std.process.exit(0); } else { input = arg; break;