this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

define cli args

Altagos dfcf8311 5f460601

+56 -38
+7 -3
build.zig
··· 4 4 const target = b.standardTargetOptions(.{}); 5 5 const optimize = b.standardOptimizeOption(.{}); 6 6 7 - const mod = b.addModule("austin_converter", .{ 7 + const mod = b.addModule("austin", .{ 8 8 .root_source_file = b.path("src/root.zig"), 9 9 .target = target, 10 10 }); ··· 16 16 .target = target, 17 17 .optimize = optimize, 18 18 .imports = &.{ 19 - .{ .name = "austin_converter", .module = mod }, 19 + .{ .name = "austin", .module = mod }, 20 20 }, 21 21 }), 22 22 }); 23 + 24 + exe.root_module.addImport("args", b.dependency("args", .{ 25 + .target = target, 26 + .optimize = optimize, 27 + }).module("args")); 23 28 24 29 b.installArtifact(exe); 25 30 ··· 49 54 const test_step = b.step("test", "Run tests"); 50 55 test_step.dependOn(&run_mod_tests.step); 51 56 test_step.dependOn(&run_exe_tests.step); 52 - 53 57 }
+4
build.zig.zon
··· 4 4 .fingerprint = 0x52068cccae2eacdd, // Changing this has security and trust implications. 5 5 .minimum_zig_version = "0.15.0-dev.876+8eca338c2", 6 6 .dependencies = .{ 7 + .args = .{ 8 + .url = "git+https://github.com/ikskuh/zig-args?ref=master#9425b94c103a031777fdd272c555ce93a7dea581", 9 + .hash = "args-0.0.0-CiLiqv_NAAC97fGpk9hS2K681jkiqPsWP6w3ucb_ctGH", 10 + }, 7 11 }, 8 12 .paths = .{ 9 13 "build.zig",
+41 -18
src/main.zig
··· 1 1 const std = @import("std"); 2 - const austin_converter = @import("austin_converter"); 2 + const args = @import("args"); 3 + 4 + const austin = @import("austin"); 5 + 6 + const Options = struct { 7 + help: bool = false, 8 + output: ?[]const u8 = null, 9 + format: austin.Formats = .chrome, 10 + 11 + pub const shorthands = .{ 12 + .h = "help", 13 + .o = "output", 14 + .f = "format", 15 + }; 16 + 17 + pub const meta = .{ 18 + .name = "austin-converter", 19 + .usage_summary = "[options] [input file]", 20 + .option_docs = .{ 21 + .output = "output file (default: stdout)", 22 + .format = "format to convert to (options: chrome, spall; default: chrome)", 23 + .help = "", 24 + }, 25 + }; 26 + }; 3 27 4 28 pub fn main() !void { 5 - std.debug.print("All your {s} are belong to us.\n", .{"codebase"}); 6 - try austin_converter.bufferedPrint(); 7 - } 29 + var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); 30 + defer arena.deinit(); 31 + const allocator = arena.allocator(); 8 32 9 - test "simple test" { 10 - var list = std.ArrayList(i32).init(std.testing.allocator); 11 - defer list.deinit(); // Try commenting this out and see if zig detects the memory leak! 12 - try list.append(42); 13 - try std.testing.expectEqual(@as(i32, 42), list.pop()); 14 - } 33 + const options = args.parseForCurrentProcess( 34 + Options, 35 + allocator, 36 + .print, 37 + ) catch return; 38 + defer options.deinit(); 15 39 16 - test "fuzz example" { 17 - const Context = struct { 18 - fn testOne(context: @This(), input: []const u8) anyerror!void { 19 - _ = context; 20 - try std.testing.expect(!std.mem.eql(u8, "canyoufindme", input)); 21 - } 22 - }; 23 - try std.testing.fuzz(Context{}, Context.testOne, .{}); 40 + if (options.options.help or std.meta.eql(options.options, Options{})) { 41 + try args.printHelp( 42 + Options, 43 + Options.meta.name, 44 + std.io.getStdOut().writer(), 45 + ); 46 + } 24 47 }
+4 -17
src/root.zig
··· 1 1 const std = @import("std"); 2 2 3 - pub fn bufferedPrint() !void { 4 - const stdout_file = std.io.getStdOut().writer(); 5 - var bw = std.io.bufferedWriter(stdout_file); 6 - const stdout = bw.writer(); 7 - 8 - try stdout.print("Run `zig build test` to run the tests.\n", .{}); 9 - 10 - try bw.flush(); // Don't forget to flush! 11 - } 12 - 13 - pub fn add(a: i32, b: i32) i32 { 14 - return a + b; 15 - } 16 - 17 - test "basic add functionality" { 18 - try std.testing.expect(add(3, 7) == 10); 19 - } 3 + pub const Formats = enum { 4 + chrome, 5 + spall, 6 + };