1414use std:: { fs, path:: Path } ;
1515
1616use oxc_allocator:: Allocator ;
17- use oxc_formatter:: { BracketSameLine , FormatOptions , Formatter , Semicolons , get_parse_options} ;
17+ use oxc_formatter:: {
18+ BracketSameLine , FormatOptions , Formatter , LineWidth , Semicolons , get_parse_options,
19+ } ;
1820use oxc_parser:: Parser ;
1921use oxc_span:: SourceType ;
2022use pico_args:: Arguments ;
@@ -24,6 +26,7 @@ fn main() -> Result<(), String> {
2426 let mut args = Arguments :: from_env ( ) ;
2527 let no_semi = args. contains ( "--no-semi" ) ;
2628 let show_ir = args. contains ( "--ir" ) ;
29+ let print_width = args. opt_value_from_str :: < & ' static str , u16 > ( "--print-width" ) . unwrap_or ( None ) ;
2730 let name = args. free_from_str ( ) . unwrap_or_else ( |_| "test.js" . to_string ( ) ) ;
2831
2932 // Read source file
@@ -46,9 +49,14 @@ fn main() -> Result<(), String> {
4649
4750 // Format the parsed code
4851 let semicolons = if no_semi { Semicolons :: AsNeeded } else { Semicolons :: Always } ;
52+ let line_width = match print_width {
53+ Some ( width) => LineWidth :: try_from ( width) . unwrap ( ) ,
54+ None => LineWidth :: try_from ( 80 ) . unwrap ( ) ,
55+ } ;
4956 let options = FormatOptions {
5057 bracket_same_line : BracketSameLine :: from ( true ) ,
5158 semicolons,
59+ line_width,
5260 ..Default :: default ( )
5361 } ;
5462
0 commit comments