help and README
This commit is contained in:
parent
8fb7891fe1
commit
1059625933
18
README.md
18
README.md
@ -5,9 +5,19 @@ A base64 encoder & decoder in Zig
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Encoding
|
# Print help
|
||||||
echo -n "hello" | baze64
|
|
||||||
|
|
||||||
# Decoding
|
# Encoding
|
||||||
echo -n "aGVsbG8=" | baze64
|
> 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
|
||||||
```
|
```
|
@ -4,9 +4,11 @@ const stdout = std.io.getStdOut().writer();
|
|||||||
const Base64 = @import("base64.zig");
|
const Base64 = @import("base64.zig");
|
||||||
|
|
||||||
const usageText =
|
const usageText =
|
||||||
\\Usage: baze64 {-d/-D} input
|
\\Usage: baze64 {-d/-D} {-h/-H} input
|
||||||
|
\\With no arguments, encodes input into a base64 string
|
||||||
\\Args:
|
\\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")) {
|
if (std.mem.eql(u8, arg, "-d") or std.mem.eql(u8, arg, "-D")) {
|
||||||
decodeSwitch = true;
|
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 {
|
} else {
|
||||||
input = arg;
|
input = arg;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user