commit 105962593321522f29005f004ebda4325bf1d5dc from: Evan Burkey date: Thu Nov 7 17:42:51 2024 UTC help and README commit - 8fb7891fe1bfed2396147321d7e595e6be6b013b commit + 105962593321522f29005f004ebda4325bf1d5dc blob - e21980ee699e15aafcc6afa4fa16a0ff97835a91 blob + bfd80ef3581e44e0d74bc5ee35a81b70f70214f4 --- README.md +++ README.md @@ -5,9 +5,19 @@ A base64 encoder & decoder in Zig ## Usage ```shell +# Print help + # Encoding -echo -n "hello" | baze64 +> baze64 "hello" -# Decoding -echo -n "aGVsbG8=" | baze64 +# 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 blob - e621fefdd7350ee436ddf1bc8f6e2f59add8aee6 blob + 27633130bfa50c3727e2a1bac85257428c1e0234 --- src/main.zig +++ 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;