From 9db6e56d1603a5fe738516b10a3b15b9209e4680 Mon Sep 17 00:00:00 2001 From: Komari Spaghetti Date: Thu, 24 Jun 2021 17:22:33 +0200 Subject: Stay under 100 chars per line in all the code --- clap/args.zig | 7 ++++++- clap/comptime.zig | 3 +-- clap/streaming.zig | 22 +++++++++++++++++----- 3 files changed, 24 insertions(+), 8 deletions(-) (limited to 'clap') diff --git a/clap/args.zig b/clap/args.zig index 555e8ab..d848eb7 100644 --- a/clap/args.zig +++ b/clap/args.zig @@ -252,7 +252,12 @@ pub const ShellIterator = struct { } } - fn result(iter: *ShellIterator, start: usize, end: usize, list: *std.ArrayList(u8)) Error!?[]const u8 { + fn result( + iter: *ShellIterator, + start: usize, + end: usize, + list: *std.ArrayList(u8), + ) Error!?[]const u8 { const res = iter.str[start..end]; // If we already have something in `list` that means that we could not diff --git a/clap/comptime.zig b/clap/comptime.zig index 7808f52..cbc872e 100644 --- a/clap/comptime.zig +++ b/clap/comptime.zig @@ -45,9 +45,8 @@ pub fn ComptimeClap( pub fn parse(iter: anytype, opt: clap.ParseOptions) !@This() { const allocator = opt.allocator; var multis = [_]std.ArrayList([]const u8){undefined} ** multi_options; - for (multis) |*multi| { + for (multis) |*multi| multi.* = std.ArrayList([]const u8).init(allocator); - } var pos = std.ArrayList([]const u8).init(allocator); diff --git a/clap/streaming.zig b/clap/streaming.zig index e2f1311..885c581 100644 --- a/clap/streaming.zig +++ b/clap/streaming.zig @@ -21,8 +21,8 @@ pub fn Arg(comptime Id: type) type { } /// A command line argument parser which, given an ArgIterator, will parse arguments according -/// to the params. StreamingClap parses in an iterating manner, so you have to use a loop together with -/// StreamingClap.next to parse all the arguments of your program. +/// to the params. StreamingClap parses in an iterating manner, so you have to use a loop +/// together with StreamingClap.next to parse all the arguments of your program. pub fn StreamingClap(comptime Id: type, comptime ArgIterator: type) type { return struct { const State = union(enum) { @@ -203,7 +203,11 @@ pub fn StreamingClap(comptime Id: type, comptime ArgIterator: type) type { }; } -fn testNoErr(params: []const clap.Param(u8), args_strings: []const []const u8, results: []const Arg(u8)) !void { +fn testNoErr( + params: []const clap.Param(u8), + args_strings: []const []const u8, + results: []const Arg(u8), +) !void { var iter = args.SliceIterator{ .args = args_strings }; var c = StreamingClap(u8, args.SliceIterator){ .params = params, @@ -225,7 +229,11 @@ fn testNoErr(params: []const clap.Param(u8), args_strings: []const []const u8, r return error.TestFailed; } -fn testErr(params: []const clap.Param(u8), args_strings: []const []const u8, expected: []const u8) !void { +fn testErr( + params: []const clap.Param(u8), + args_strings: []const []const u8, + expected: []const u8, +) !void { var diag: clap.Diagnostic = undefined; var iter = args.SliceIterator{ .args = args_strings }; var c = StreamingClap(u8, args.SliceIterator){ @@ -420,5 +428,9 @@ test "errors" { try testErr(¶ms, &.{"-a=1"}, "The argument '-a' does not take a value\n"); try testErr(¶ms, &.{"--aa=1"}, "The argument '--aa' does not take a value\n"); try testErr(¶ms, &.{"-c"}, "The argument '-c' requires a value but none was supplied\n"); - try testErr(¶ms, &.{"--cc"}, "The argument '--cc' requires a value but none was supplied\n"); + try testErr( + ¶ms, + &.{"--cc"}, + "The argument '--cc' requires a value but none was supplied\n", + ); } -- cgit v1.2.3