parent
c88a2815fa
commit
12e96454ff
11
src/main.zig
11
src/main.zig
|
@ -9,7 +9,8 @@ pub fn main() !void {
|
||||||
|
|
||||||
const params = comptime clap.parseParamsComptime(
|
const params = comptime clap.parseParamsComptime(
|
||||||
\\-h, --help display this help and exit
|
\\-h, --help display this help and exit
|
||||||
\\<FILE> file to read from, if empty or "-" use stdin.
|
\\-v, --version display the version and exit
|
||||||
|
\\<FILE> file to read from, empty or "-" use stdin
|
||||||
\\
|
\\
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -27,8 +28,14 @@ pub fn main() !void {
|
||||||
};
|
};
|
||||||
defer res.deinit();
|
defer res.deinit();
|
||||||
|
|
||||||
|
if (res.args.help != 0) return clap.help(std.io.getStdErr().writer(), clap.Help, ¶ms, .{});
|
||||||
|
|
||||||
|
const version_string = "0.1.1\n";
|
||||||
|
|
||||||
|
if (res.args.version != 0) return std.debug.print(version_string, .{});
|
||||||
|
|
||||||
var reader: std.io.AnyReader = undefined;
|
var reader: std.io.AnyReader = undefined;
|
||||||
if (res.positionals.len < 1) {
|
if (res.positionals.len < 1 or std.mem.eql(u8, res.positionals[0], "-")) {
|
||||||
reader = std.io.getStdIn().reader().any();
|
reader = std.io.getStdIn().reader().any();
|
||||||
} else {
|
} else {
|
||||||
const filename = res.positionals[0];
|
const filename = res.positionals[0];
|
||||||
|
|
Loading…
Reference in New Issue