Skip to content

Commit 4e0aea2

Browse files
authored
Implement formatter (#59)
- [ ] Bug fix - [x] New feature - [ ] Other
2 parents 87ef955 + fd4e073 commit 4e0aea2

4 files changed

Lines changed: 826 additions & 6 deletions

File tree

‎cmd/fun/main.zig‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ fn print_error_and_exit(err: anyerror) noreturn {
3838
cli.CliError.ShowHelp => {
3939
std.process.exit(0);
4040
},
41+
// Formatting uses the same lexer/transpiler error types; they are printed elsewhere.
4142
error.FileNotFound => {
4243
_ = stderr.writeAll("Error: Input file not found\n") catch {};
4344
},
@@ -64,6 +65,16 @@ pub fn main() void {
6465

6566
const options = cli.parse_args(global_allocator) catch |err| print_error_and_exit(err);
6667

68+
if (options.fmt_all) {
69+
cli.format_file_and_imports_in_place(global_allocator, options.input_file) catch |err| print_error_and_exit(err);
70+
return;
71+
}
72+
73+
if (options.fmt) {
74+
cli.format_file_in_place(global_allocator, options.input_file) catch |err| print_error_and_exit(err);
75+
return;
76+
}
77+
6778
var tp = codegen.TranspileProcess.init(
6879
global_allocator,
6980
options.input_file,

0 commit comments

Comments
 (0)