@@ -2,7 +2,7 @@ const std = @import("std");
22const bofs = @import ("bof-launcher" );
33const yaml = @import ("yaml" );
44
5- pub const std_options = . {
5+ pub const std_options = std.Options {
66 .log_level = .info ,
77};
88
@@ -147,6 +147,10 @@ pub fn main() !u8 {
147147 defer _ = gpa .deinit ();
148148 const allocator = gpa .allocator ();
149149
150+ var arena = std .heap .ArenaAllocator .init (allocator );
151+ defer arena .deinit ();
152+ const arena_allocator = arena .allocator ();
153+
150154 ///////////////////////////////////////////////////////////
151155 // 1. look for BOF-collection.yaml file in cwd
152156 // 2. parse it if available and store results in the ArrayList
@@ -160,14 +164,15 @@ pub fn main() !u8 {
160164 const source = try file .readToEndAlloc (allocator , std .math .maxInt (u32 ));
161165 defer allocator .free (source );
162166
163- var yaml_file = try yaml .Yaml .load (allocator , source );
164- errdefer yaml_file .deinit ();
167+ var yaml_file : yaml.Yaml = .{ .source = source };
168+ errdefer yaml_file .deinit (allocator );
169+ try yaml_file .load (allocator );
165170
166- const bofs_collection = try yaml_file .parse ([]BofRecord );
171+ const bofs_collection = try yaml_file .parse (arena_allocator , []BofRecord );
167172
168173 break :blk .{ bofs_collection , yaml_file };
169174 };
170- defer if (yaml_file ) | yf | @constCast (& yf ).* .deinit ();
175+ defer if (yaml_file ) | yf | @constCast (& yf ).* .deinit (allocator );
171176
172177 ///////////////////////////////////////////////////////////
173178 // commands processing:
@@ -196,7 +201,7 @@ pub fn main() !u8 {
196201
197202 var cmd : Cmd = undefined ;
198203 var bof_name : [:0 ]const u8 = undefined ;
199- var bof_path_buffer : [std .fs .MAX_PATH_BYTES :0 ]u8 = undefined ;
204+ var bof_path_buffer : [std .fs .max_path_bytes :0 ]u8 = undefined ;
200205
201206 var list_tag : []u8 = undefined ;
202207 var list_by_tag : bool = false ;
@@ -304,7 +309,7 @@ pub fn main() !u8 {
304309 for (cmd_args [3.. ]) | arg | {
305310 // handle case when file:<filepath> argument is provided
306311 if (mem .indexOf (u8 , arg , "file:" ) != null ) {
307- var iter = mem .tokenize (u8 , arg , ":" );
312+ var iter = mem .tokenizeScalar (u8 , arg , ':' );
308313
309314 _ = iter .next () orelse return error .BadData ;
310315 const file_path = iter .next () orelse return error .BadData ;
@@ -340,7 +345,6 @@ pub fn main() !u8 {
340345 .info = > {
341346 for (bofs_collection ) | bof | {
342347 if (std .mem .eql (u8 , bof_name , bof .name )) {
343-
344348 try stdout .print ("Name: {s}\n " , .{bof .name });
345349 try stdout .print ("Description: {s}\n " , .{bof .description });
346350 try stdout .print ("BOF authors(s): {s}\n " , .{bof .author });
@@ -399,7 +403,7 @@ pub fn main() !u8 {
399403 if (bof .errors ) | errors | for (errors ) | err | {
400404 try stdout .print ("{s} ({x}) : {s}\n " , .{ err .name , err .code , err .message });
401405 };
402-
406+
403407 try stdout .print ("\n EXAMPLES: {s}\n " , .{bof .examples });
404408 }
405409 }
@@ -436,7 +440,7 @@ pub fn main() !u8 {
436440 try stdout .print ("info <BOF> - Display BOF description and usage examples\n " , .{});
437441 } else if (std .mem .eql (u8 , cmd_help , "list" )) {
438442 try stdout .print ("list [TAG] - List BOFs (all or based on TAG) from BOF-collection.yaml file\n " , .{});
439- } else if (std .mem .eql (u8 , cmd_help , "help" )) {
443+ } else if (std .mem .eql (u8 , cmd_help , "help" )) {
440444 try stdout .print ("help <COMMAND> - Display help about given command\n " , .{});
441445 } else {
442446 try stderr .writeAll ("Fatal: unrecognized command provided. Aborting.\n " );
0 commit comments