feat: add more useful message if no parser was found
This commit is contained in:
parent
2ad1ae7c02
commit
64aab6048a
1 changed files with 11 additions and 4 deletions
15
src/main.zig
15
src/main.zig
|
@ -74,11 +74,18 @@ pub fn main() !void {
|
||||||
try bw.flush();
|
try bw.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_file(a: std.mem.Allocator, writer: anytype, content: []const u8, file_path: []const u8, theme: *const Theme) !void {
|
fn get_parser(a: std.mem.Allocator, content: []const u8, file_path: []const u8) *syntax {
|
||||||
const parser = if (lang_override) |name|
|
return (if (lang_override) |name|
|
||||||
try syntax.create_file_type(a, content, name)
|
syntax.create_file_type(a, content, name)
|
||||||
else
|
else
|
||||||
try syntax.create_guess_file_type(a, content, file_path);
|
syntax.create_guess_file_type(a, content, file_path)) catch {
|
||||||
|
std.io.getStdErr().writer().writeAll("unknown file type. override with --lang\n") catch {};
|
||||||
|
std.os.exit(1);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render_file(a: std.mem.Allocator, writer: anytype, content: []const u8, file_path: []const u8, theme: *const Theme) !void {
|
||||||
|
const parser = get_parser(a, content, file_path);
|
||||||
|
|
||||||
const Ctx = struct {
|
const Ctx = struct {
|
||||||
writer: @TypeOf(writer),
|
writer: @TypeOf(writer),
|
||||||
|
|
Loading…
Add table
Reference in a new issue