Skip to content

Commit

Permalink
Fix clippy error
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Mar 18, 2023
1 parent 94c8cfb commit 0f07439
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions boa_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,33 +262,17 @@ fn generate_flowgraph(
Ok(result)
}

fn main() -> Result<(), io::Error> {
let args = Opt::parse();

let queue = Jobs::default();
let mut context = ContextBuilder::new()
.job_queue(&queue)
.build()
.expect("cannot fail with default global object");

// Strict mode
context.strict(args.strict);

// Trace Output
context.set_trace(args.trace);
context.optimize(args.optimize);
context.optimizer_statistics(args.optimizer_statistics);

fn evaluate_files(args: &Opt, context: &mut Context<'_>) -> Result<(), io::Error> {
for file in &args.files {
let buffer = read(file)?;

if args.has_dump_flag() {
if let Err(e) = dump(&buffer, &args, &mut context) {
if let Err(e) = dump(&buffer, args, context) {
eprintln!("{e}");
}
} else if let Some(flowgraph) = args.flowgraph {
match generate_flowgraph(
&mut context,
context,
&buffer,
flowgraph.unwrap_or(FlowgraphFormat::Graphviz),
args.flowgraph_direction,
Expand All @@ -305,6 +289,26 @@ fn main() -> Result<(), io::Error> {
}
}

Ok(())
}

fn main() -> Result<(), io::Error> {
let args = Opt::parse();

let queue = Jobs::default();
let mut context = ContextBuilder::new()
.job_queue(&queue)
.build()
.expect("cannot fail with default global object");

// Strict mode
context.strict(args.strict);

// Trace Output
context.set_trace(args.trace);
context.optimize(args.optimize);
context.optimizer_statistics(args.optimizer_statistics);

if args.files.is_empty() {
let config = Config::builder()
.keyseq_timeout(1)
Expand Down Expand Up @@ -378,6 +382,8 @@ fn main() -> Result<(), io::Error> {
editor
.save_history(CLI_HISTORY)
.expect("could not save CLI history");
} else {
evaluate_files(&args, &mut context)?;
}

Ok(())
Expand Down

0 comments on commit 0f07439

Please sign in to comment.