forked from joegm/flags
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflags.zig
More file actions
29 lines (25 loc) · 812 Bytes
/
Copy pathflags.zig
File metadata and controls
29 lines (25 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const std = @import("std");
pub const ColorScheme = @import("ColorScheme.zig");
const Parser = @import("Parser.zig");
const Help = @import("Help.zig");
pub const Options = struct {
skip_first_arg: bool = true,
/// Terminal colors used when printing help and error messages. A default theme is provided.
/// To disable colors completely, pass an empty colorscheme: `&.{}`.
colors: *const ColorScheme = &.default,
};
pub fn parse(
io: std.Io,
args: []const [:0]const u8,
/// The name of your program.
comptime exe_name: []const u8,
Flags: type,
options: Options,
) Flags {
var parser = Parser{
.args = args,
.current_arg = if (options.skip_first_arg) 1 else 0,
.colors = options.colors,
};
return parser.parse(io, Flags, exe_name);
}