Skip to content

Commit

Permalink
Add --strict flag to cli (#2689)
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
HalidOdat committed Mar 18, 2023
1 parent b2b079b commit 7e6d3c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ Arguments:
The JavaScript file(s) to be evaluated

Options:
--strict
Run in strict mode

-a, --dump-ast [<FORMAT>]
Dump the AST to stdout with the given format

Expand Down
7 changes: 7 additions & 0 deletions boa_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ struct Opt {
#[arg(name = "FILE", value_hint = ValueHint::FilePath)]
files: Vec<PathBuf>,

/// Run in strict mode.
#[arg(long)]
strict: bool,

/// Dump the AST to stdout with the given format.
#[arg(
long,
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 7e6d3c9

Please sign in to comment.