-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted README to be more fine tuned and informational. Adjusting li…
…b to mark selected API elemetns as pub. Adjusted main to showcase a quick example of parsing and API usage. Adjusted sneaky to perform most fundamental parsing operations
- Loading branch information
1 parent
096efe1
commit 3739f7e
Showing
4 changed files
with
300 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
const snek = @import("sneaky.zig"); | ||
const Snek = snek.Snek; | ||
pub const Snek = snek.Snek; | ||
pub const CliError = snek.CliError; // Exposes the Error strcut type to allow users different error handling if desired |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
const std = @import("std"); | ||
const snek = @import("lib.zig").Snek; | ||
|
||
pub fn main() !void {} | ||
// Binary is also compiled for showcasing how to use the API | ||
const T = struct { | ||
name: []const u8, | ||
location: u32, | ||
exists: bool, | ||
necessary: ?bool, | ||
filled_optional: ?[]const u8, | ||
default_name: []const u8 = "test default name", | ||
}; | ||
|
||
pub fn main() !void { | ||
var cli = try snek(T).init(std.heap.page_allocator); | ||
const parsed_cli = try cli.parse(); | ||
|
||
// Necessary is skipped here | ||
std.debug.print("{s} {d} {any} {s} {s}", .{ parsed_cli.name, parsed_cli.location, parsed_cli.exists, parsed_cli.default_name, if (parsed_cli.filled_optional) |filled| filled orelse "badvalue" }); | ||
} |
Oops, something went wrong.