@@ -33,12 +33,12 @@ pub const CLI = struct {
3333 return CLI {
3434 .allocator = allocator ,
3535 .name = try allocator .dupe (u8 , name ),
36- .commands = std . ArrayList ( Command ). init ( allocator ) ,
36+ .commands = .{} ,
3737 .global_command = global_cmd ,
3838 .matched_command = null ,
3939 .matched_command_name = null ,
4040 .raw_args = &[_ ][]const u8 {},
41- .args = std . ArrayList ([] const u8 ). init ( allocator ) ,
41+ .args = .{} ,
4242 .options = std .StringHashMap ([]const u8 ).init (allocator ),
4343 .show_help_on_exit = false ,
4444 .show_version_on_exit = false ,
@@ -68,7 +68,7 @@ pub const CLI = struct {
6868 pub fn command (self : * CLI , raw_name : []const u8 , description : []const u8 , config : types.CommandConfig ) ! * Command {
6969 var cmd = try Command .init (self .allocator , raw_name , description , config );
7070 cmd .cli = @ptrCast (self );
71- try self .commands .append (cmd );
71+ try self .commands .append (self . allocator , cmd );
7272
7373 // Return pointer to the command in the ArrayList
7474 return & self .commands .items [self .commands .items .len - 1 ];
@@ -139,7 +139,7 @@ pub const CLI = struct {
139139 // Copy args (skipping command name)
140140 self .args .clearRetainingCapacity ();
141141 for (parsed .args .items [1.. ]) | arg | {
142- try self .args .append (try self .allocator .dupe (u8 , arg ));
142+ try self .args .append (self . allocator , try self .allocator .dupe (u8 , arg ));
143143 }
144144
145145 // Copy options
@@ -169,7 +169,7 @@ pub const CLI = struct {
169169
170170 self .args .clearRetainingCapacity ();
171171 for (parsed .args .items ) | arg | {
172- try self .args .append (try self .allocator .dupe (u8 , arg ));
172+ try self .args .append (self . allocator , try self .allocator .dupe (u8 , arg ));
173173 }
174174
175175 self .options .clearRetainingCapacity ();
@@ -211,19 +211,19 @@ pub const CLI = struct {
211211
212212 /// Parse command line arguments
213213 fn parseArgs (self : * CLI , argv : []const []const u8 , cmd : ? * Command ) ! types.ParsedArgv {
214- var parsed_args = std .ArrayList ([]const u8 ). init ( self . allocator ) ;
214+ var parsed_args : std .ArrayList ([]const u8 ) = .{} ;
215215 var parsed_options = std .StringHashMap ([]const u8 ).init (self .allocator );
216216
217217 // Collect all options (global + command-specific)
218- var all_options = std .ArrayList (* const Option ). init ( self . allocator ) ;
218+ var all_options : std .ArrayList (* const Option ) = .{} ;
219219 defer all_options .deinit ();
220220
221221 for (self .global_command .options .items ) | * opt | {
222- try all_options .append (opt );
222+ try all_options .append (self . allocator , opt );
223223 }
224224 if (cmd ) | matched_cmd | {
225225 for (matched_cmd .options .items ) | * opt | {
226- try all_options .append (opt );
226+ try all_options .append (self . allocator , opt );
227227 }
228228 }
229229
@@ -287,7 +287,7 @@ pub const CLI = struct {
287287 }
288288 } else {
289289 // Regular argument
290- try parsed_args .append (try self .allocator .dupe (u8 , arg ));
290+ try parsed_args .append (self . allocator , try self .allocator .dupe (u8 , arg ));
291291 }
292292 }
293293
0 commit comments