@@ -51,59 +51,14 @@ const impl = struct {
5151 _ = cwd ;
5252
5353 const options = try parseArguments (allocator , io , args , exe_path );
54- log .debug ("options= {}" , .{options });
54+ log .debug ("{}" , .{options });
5555
5656 return switch (options .mode ) {
5757 .single = > singleArgument (allocator , io , args , exe_path , options ),
5858 .multiple = > multipleArguments (io , args , options ),
5959 };
6060 }
6161
62- const BasenameOptions = struct {
63- line_end : LineEnd = .newline ,
64- mode : Mode = .single ,
65- first_arg : []const u8 = undefined ,
66-
67- const LineEnd = enum (u8 ) {
68- newline = '\n ' ,
69- zero = 0 ,
70- };
71-
72- const Mode = union (enum ) {
73- single ,
74- /// Value is optional suffix
75- multiple : ? []const u8 ,
76- };
77-
78- pub fn format (
79- options : BasenameOptions ,
80- comptime _ : []const u8 ,
81- _ : std.fmt.FormatOptions ,
82- writer : anytype ,
83- ) ! void {
84- try writer .writeAll ("BasenameOptions{ .line_end = ." );
85- try writer .writeAll (@tagName (options .line_end ));
86-
87- try writer .writeAll (", .mode = " );
88- switch (options .mode ) {
89- .single = > try writer .writeAll (".single" ),
90- .multiple = > | opt_suffix | {
91- if (opt_suffix ) | suffix | {
92- try writer .writeAll ("{ .multiple = .{ .suffix = \" " );
93- try writer .writeAll (suffix );
94- try writer .writeAll ("\" } }" );
95- } else {
96- try writer .writeAll (".multiple" );
97- }
98- },
99- }
100-
101- try writer .writeAll (", .first_arg = \" " );
102- try writer .writeAll (options .first_arg );
103- try writer .writeAll ("\" }" );
104- }
105- };
106-
10762 fn singleArgument (
10863 allocator : std.mem.Allocator ,
10964 io : IO ,
@@ -178,6 +133,53 @@ const impl = struct {
178133 return basename [0.. end_index ];
179134 }
180135
136+ const BasenameOptions = struct {
137+ line_end : LineEnd = .newline ,
138+ mode : Mode = .single ,
139+ first_arg : []const u8 = undefined ,
140+
141+ const LineEnd = enum (u8 ) {
142+ newline = '\n ' ,
143+ zero = 0 ,
144+ };
145+
146+ const Mode = union (enum ) {
147+ single ,
148+ /// Value is optional suffix
149+ multiple : ? []const u8 ,
150+ };
151+
152+ pub fn format (
153+ options : BasenameOptions ,
154+ comptime _ : []const u8 ,
155+ _ : std.fmt.FormatOptions ,
156+ writer : anytype ,
157+ ) ! void {
158+ try writer .writeAll ("BasenameOptions {" );
159+
160+ try writer .writeAll (comptime "\n " ++ shared .option_log_indentation ++ ".line_end = ." );
161+ try writer .writeAll (@tagName (options .line_end ));
162+
163+ try writer .writeAll (comptime ",\n " ++ shared .option_log_indentation ++ ".mode = " );
164+ switch (options .mode ) {
165+ .single = > try writer .writeAll (".single" ),
166+ .multiple = > | opt_suffix | {
167+ if (opt_suffix ) | suffix | {
168+ try writer .writeAll ("{ .multiple = .{ .suffix = \" " );
169+ try writer .writeAll (suffix );
170+ try writer .writeAll ("\" } }" );
171+ } else {
172+ try writer .writeAll (".multiple" );
173+ }
174+ },
175+ }
176+
177+ try writer .writeAll (comptime ",\n " ++ shared .option_log_indentation ++ ".first_arg = \" " );
178+ try writer .writeAll (options .first_arg );
179+ try writer .writeAll ("\" ,\n }" );
180+ }
181+ };
182+
181183 fn parseArguments (
182184 allocator : std.mem.Allocator ,
183185 io : IO ,
0 commit comments