-
Notifications
You must be signed in to change notification settings - Fork 2
Import Guide
Joe Mckay edited this page May 25, 2024
·
3 revisions
This guide will show you how to add a dependency on flags in your project.
At the time of writing, Zig's package manager is quite minimal. If this guide appears outdated, please open an issue.
First go to the latest release and copy the link to the source code archive (.tar.gz
format).
To import straight from the master branch, use "https://github.com/n0s4/flags/archive/refs/heads/main.tar.gz" instead
Run this command in your project:
$ zig fetch --save https://copied/link/vX.Y.Z.tar.gz
This should add a dependency entry in your build.zig.zon
.
Open your project's build.zig
script and add this:
pub fn build(b: *std.Build) void {
// const target = b.standardTargetOptions(.{});
// const optimize = b.standardOptimizeOption(.{});
// const exe = b.addExecutable(...);
const flags = b.dependency("flags", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("flags", flags.module("flags"));
// b.installArtifact(exe);
}
Verify this is working in your main.zig
by importing the module however you like:
const parseArgs = @import("flags").parse;