Browse Source

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`
pull/2691/head
Haled Odat 2 years ago
parent
commit
7e6d3c9209
  1. 3
      README.md
  2. 7
      boa_cli/src/main.rs

3
README.md

@ -82,6 +82,9 @@ Arguments:
The JavaScript file(s) to be evaluated The JavaScript file(s) to be evaluated
Options: Options:
--strict
Run in strict mode
-a, --dump-ast [<FORMAT>] -a, --dump-ast [<FORMAT>]
Dump the AST to stdout with the given format Dump the AST to stdout with the given format

7
boa_cli/src/main.rs

@ -94,6 +94,10 @@ struct Opt {
#[arg(name = "FILE", value_hint = ValueHint::FilePath)] #[arg(name = "FILE", value_hint = ValueHint::FilePath)]
files: Vec<PathBuf>, files: Vec<PathBuf>,
/// Run in strict mode.
#[arg(long)]
strict: bool,
/// Dump the AST to stdout with the given format. /// Dump the AST to stdout with the given format.
#[arg( #[arg(
long, long,
@ -256,6 +260,9 @@ fn main() -> Result<(), io::Error> {
.build() .build()
.expect("cannot fail with default global object"); .expect("cannot fail with default global object");
// Strict mode
context.strict(args.strict);
// Trace Output // Trace Output
context.set_trace(args.trace); context.set_trace(args.trace);

Loading…
Cancel
Save