From 7e6d3c92096925580c081e3daa59292900fd724b Mon Sep 17 00:00:00 2001 From: Haled Odat Date: Sat, 18 Mar 2023 03:30:22 +0000 Subject: [PATCH] Add `--strict` flag to cli (#2689) This PR adds the `--strict` flag to the CLI that enables strict mode on file/interactive mode execution. It's a bit annoying to have to prefix with `'use strict';` when trying to debug in interactive mode ```js >>> 'use strict'; .... // :( ``` It changes the following: - Adds `--strict` flag to CLI - update `README.md` --- README.md | 3 +++ boa_cli/src/main.rs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 3ae24be2a0e..b5230b8d462 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,9 @@ Arguments: The JavaScript file(s) to be evaluated Options: + --strict + Run in strict mode + -a, --dump-ast [] Dump the AST to stdout with the given format diff --git a/boa_cli/src/main.rs b/boa_cli/src/main.rs index b36c6d28c0c..98d759f0d89 100644 --- a/boa_cli/src/main.rs +++ b/boa_cli/src/main.rs @@ -94,6 +94,10 @@ struct Opt { #[arg(name = "FILE", value_hint = ValueHint::FilePath)] files: Vec, + /// Run in strict mode. + #[arg(long)] + strict: bool, + /// Dump the AST to stdout with the given format. #[arg( long, @@ -256,6 +260,9 @@ fn main() -> Result<(), io::Error> { .build() .expect("cannot fail with default global object"); + // Strict mode + context.strict(args.strict); + // Trace Output context.set_trace(args.trace);