refactor(config): BREAKING rename config option config_files to include_files
This commit is contained in:
		
							parent
							
								
									eaa7ad87b7
								
							
						
					
					
						commit
						1acc9b107e
					
				
					 4 changed files with 10 additions and 10 deletions
				
			
		|  | @ -23,4 +23,4 @@ bottom_bar: []const u8 = "mode file log selection diagnostics keybind linenumber | ||||||
| 
 | 
 | ||||||
| lsp_request_timeout: usize = 10, | lsp_request_timeout: usize = 10, | ||||||
| 
 | 
 | ||||||
| config_files: []const u8 = "", | include_files: []const u8 = "", | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| fontface: [] const u8 = "Cascadia Code", | fontface: [] const u8 = "Cascadia Code", | ||||||
| fontsize: f32 = 17.5, | fontsize: f32 = 17.5, | ||||||
| 
 | 
 | ||||||
| config_files: []const u8 = "", | include_files: []const u8 = "", | ||||||
|  |  | ||||||
							
								
								
									
										14
									
								
								src/main.zig
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								src/main.zig
									
										
									
									
									
								
							|  | @ -398,7 +398,7 @@ pub fn read_config(T: type, allocator: std.mem.Allocator) struct { T, [][]const | ||||||
|     const file_name = get_app_config_file_name(application_name, @typeName(T)) catch return .{ .{}, bufs }; |     const file_name = get_app_config_file_name(application_name, @typeName(T)) catch return .{ .{}, bufs }; | ||||||
|     var conf: T = .{}; |     var conf: T = .{}; | ||||||
|     read_config_file(T, allocator, &conf, &bufs, file_name); |     read_config_file(T, allocator, &conf, &bufs, file_name); | ||||||
|     read_nested_config_files(T, allocator, &conf, &bufs); |     read_nested_include_files(T, allocator, &conf, &bufs); | ||||||
|     return .{ conf, bufs }; |     return .{ conf, bufs }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -428,12 +428,12 @@ fn read_json_config_file(T: type, allocator: std.mem.Allocator, conf: *T, bufs_: | ||||||
|         var field_name: []const u8 = undefined; |         var field_name: []const u8 = undefined; | ||||||
|         if (!(try cbor.matchString(&iter, &field_name))) return error.InvalidConfig; |         if (!(try cbor.matchString(&iter, &field_name))) return error.InvalidConfig; | ||||||
|         inline for (@typeInfo(T).Struct.fields) |field_info| |         inline for (@typeInfo(T).Struct.fields) |field_info| | ||||||
|             if (comptime std.mem.eql(u8, "config_files", field_info.name)) { |             if (comptime std.mem.eql(u8, "include_files", field_info.name)) { | ||||||
|                 if (std.mem.eql(u8, field_name, field_info.name)) { |                 if (std.mem.eql(u8, field_name, field_info.name)) { | ||||||
|                     var value: field_info.type = undefined; |                     var value: field_info.type = undefined; | ||||||
|                     if (!(try cbor.matchValue(&iter, cbor.extract(&value)))) return error.InvalidConfig; |                     if (!(try cbor.matchValue(&iter, cbor.extract(&value)))) return error.InvalidConfig; | ||||||
|                     if (conf.config_files.len > 0) { |                     if (conf.include_files.len > 0) { | ||||||
|                         std.log.err("{s}: ignoring nested 'config_files' value '{s}'", .{ file_name, value }); |                         std.log.err("{s}: ignoring nested 'include_files' value '{s}'", .{ file_name, value }); | ||||||
|                     } else { |                     } else { | ||||||
|                         @field(conf, field_info.name) = value; |                         @field(conf, field_info.name) = value; | ||||||
|                     } |                     } | ||||||
|  | @ -446,9 +446,9 @@ fn read_json_config_file(T: type, allocator: std.mem.Allocator, conf: *T, bufs_: | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn read_nested_config_files(T: type, allocator: std.mem.Allocator, conf: *T, bufs: *[][]const u8) void { | fn read_nested_include_files(T: type, allocator: std.mem.Allocator, conf: *T, bufs: *[][]const u8) void { | ||||||
|     if (conf.config_files.len == 0) return; |     if (conf.include_files.len == 0) return; | ||||||
|     var it = std.mem.splitScalar(u8, conf.config_files, std.fs.path.delimiter); |     var it = std.mem.splitScalar(u8, conf.include_files, std.fs.path.delimiter); | ||||||
|     while (it.next()) |path| read_config_file(T, allocator, conf, bufs, path); |     while (it.next()) |path| read_config_file(T, allocator, conf, bufs, path); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -92,7 +92,7 @@ fn init(allocator: Allocator) !*Self { | ||||||
|     conf.input_mode = try allocator.dupe(u8, conf.input_mode); |     conf.input_mode = try allocator.dupe(u8, conf.input_mode); | ||||||
|     conf.top_bar = try allocator.dupe(u8, conf.top_bar); |     conf.top_bar = try allocator.dupe(u8, conf.top_bar); | ||||||
|     conf.bottom_bar = try allocator.dupe(u8, conf.bottom_bar); |     conf.bottom_bar = try allocator.dupe(u8, conf.bottom_bar); | ||||||
|     conf.config_files = try allocator.dupe(u8, conf.config_files); |     conf.include_files = try allocator.dupe(u8, conf.include_files); | ||||||
|     if (build_options.gui) conf.enable_terminal_cursor = false; |     if (build_options.gui) conf.enable_terminal_cursor = false; | ||||||
| 
 | 
 | ||||||
|     const frame_rate: usize = @intCast(tp.env.get().num("frame-rate")); |     const frame_rate: usize = @intCast(tp.env.get().num("frame-rate")); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue