refactor: make available write_padding function to other modules
This commit is contained in:
parent
ced915fedc
commit
c5e6d64235
3 changed files with 14 additions and 9 deletions
|
|
@ -668,6 +668,7 @@ pub fn build_exe(
|
|||
exe.root_module.addImport("flags", flags_dep.module("flags"));
|
||||
exe.root_module.addImport("cbor", cbor_mod);
|
||||
exe.root_module.addImport("config", config_mod);
|
||||
exe.root_module.addImport("text_manip", text_manip_mod);
|
||||
exe.root_module.addImport("Buffer", Buffer_mod);
|
||||
exe.root_module.addImport("tui", tui_mod);
|
||||
exe.root_module.addImport("thespian", thespian_mod);
|
||||
|
|
@ -717,6 +718,7 @@ pub fn build_exe(
|
|||
check_exe.root_module.addImport("flags", flags_dep.module("flags"));
|
||||
check_exe.root_module.addImport("cbor", cbor_mod);
|
||||
check_exe.root_module.addImport("config", config_mod);
|
||||
check_exe.root_module.addImport("text_manip", text_manip_mod);
|
||||
check_exe.root_module.addImport("Buffer", Buffer_mod);
|
||||
check_exe.root_module.addImport("tui", tui_mod);
|
||||
check_exe.root_module.addImport("thespian", thespian_mod);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
const std = @import("std");
|
||||
const file_type_config = @import("file_type_config");
|
||||
const text_manip = @import("text_manip");
|
||||
const write_string = text_manip.write_string;
|
||||
const write_padding = text_manip.write_padding;
|
||||
const builtin = @import("builtin");
|
||||
const RGB = @import("color").RGB;
|
||||
|
||||
|
|
@ -66,11 +69,6 @@ fn args_string_length(args_: ?[]const []const u8) usize {
|
|||
return len;
|
||||
}
|
||||
|
||||
fn write_string(writer: anytype, string: []const u8, pad: ?usize) !void {
|
||||
try writer.writeAll(string);
|
||||
if (pad) |pad_| try write_padding(writer, string.len, pad_);
|
||||
}
|
||||
|
||||
fn write_checkmark(writer: anytype, success: bool, tty_config: std.io.tty.Config) !void {
|
||||
try tty_config.setColor(writer, if (success) .green else .red);
|
||||
if (success) try writer.writeAll(success_mark) else try writer.writeAll(fail_mark);
|
||||
|
|
@ -98,10 +96,6 @@ fn write_segmented(
|
|||
if (pad) |pad_| try write_padding(writer, len, pad_);
|
||||
}
|
||||
|
||||
fn write_padding(writer: anytype, len: usize, pad_len: usize) !void {
|
||||
for (0..pad_len - len) |_| try writer.writeAll(" ");
|
||||
}
|
||||
|
||||
fn can_execute(allocator: std.mem.Allocator, binary_name: []const u8) bool {
|
||||
const resolved_binary_path = bin_path.find_binary_in_path(allocator, binary_name) catch return false;
|
||||
defer if (resolved_binary_path) |path| allocator.free(path);
|
||||
|
|
|
|||
|
|
@ -89,3 +89,12 @@ pub fn toggle_prefix_in_text(prefix: []const u8, text: []const u8, allocator: st
|
|||
}
|
||||
return result.toOwnedSlice(allocator);
|
||||
}
|
||||
|
||||
pub fn write_string(writer: anytype, string: []const u8, pad: ?usize) !void {
|
||||
try writer.writeAll(string);
|
||||
if (pad) |pad_| try write_padding(writer, string.len, pad_);
|
||||
}
|
||||
|
||||
pub fn write_padding(writer: anytype, len: usize, pad_len: usize) !void {
|
||||
for (0..pad_len - len) |_| try writer.writeAll(" ");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue