SysExits for Zig#
This library provides the SysExit constants from BSD sysexits.h
Add to your project#
Add the package to your build.zig.zon:
zig fetch --save git+https://tangled.org/@matrixfurry.com/sysexits
Import the package in your build.zig:
const sysexits = b.dependency("sysexits", .{}).module("sysexits");
exe.root_module.addImport("sysexits", sysexits);
Usage#
Use the constants provided by this library:
const sysexits = @import("sysexits");
pub fn main() !u8 {
// Oh no, the command was used incorrectly!
return sysexits.usage;
// Yay, everything worked correctly!
return sysexits.ok;
}
Or with std.process.exit():
const std = @import("std");
const sysexits = @import("sysexits");
pub fn main() !void {
// Oh no, the command was used incorrectly!
std.process.exit(sysexits.usage);
// Yay, everything worked correctly!
std.process.exit(sysexits.ok);
}