File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 1+ //! This is a simple CLI utility to take in an FTL file and output the AST.
2+ //!
3+ //! ## View the `Debug` representation:
4+ //!
5+ //! From the root directory of the `fluent-rs` repo:
6+ //!
7+ //! ```sh
8+ //! cargo run --bin parser -- ./fluent-syntax/tests/fixtures/literal_expressions.ftl
9+ //! ```
10+ //!
11+ //! ## View the `json` representation:
12+ //!
13+ //! ```sh
14+ //! cargo run --bin parser --features json -- ./fluent-syntax/tests/fixtures/literal_expressions.ftl
15+ //! ```
16+
117use fluent_syntax:: parser:: parse;
218use std:: env;
319use std:: fs:: File ;
@@ -13,7 +29,8 @@ fn read_file(path: &str) -> Result<String, io::Error> {
1329
1430fn main ( ) {
1531 let args: Vec < String > = env:: args ( ) . collect ( ) ;
16- let source = read_file ( args. get ( 1 ) . expect ( "Pass an argument" ) ) . expect ( "Failed to fetch file" ) ;
32+ let source = read_file ( args. get ( 1 ) . expect ( "Pass a file path as the first argument" ) )
33+ . expect ( "Failed to fetch file" ) ;
1734
1835 let ( ast, errors) = match parse ( source. as_str ( ) ) {
1936 Ok ( ast) => ( ast, None ) ,
Original file line number Diff line number Diff line change 1+ //! Run the `update_fixtures` binary after updating any of the `benches` `.ftl` fixtures.
2+ //! This will update the `.json` files used in reference tests.
3+ //!
4+ //! This file must be run from `{PROJECT_ROOT}/fluent-syntax`
5+ //!
6+ //! ```sh
7+ //! cargo run --bin update_fixtures --features="json"
8+ //! ```
19use std:: fs;
210use std:: io;
311
@@ -17,7 +25,9 @@ fn main() {
1725
1826 for sample in samples {
1927 let path = format ! ( "./benches/{}.ftl" , sample) ;
20- let source = read_file ( & path) . unwrap ( ) ;
28+ let source = read_file ( & path) . expect (
29+ "Could not read the benches file. Are you running this from the correct directory? It must be run from `{PROJECT_ROOT}/fluent-syntax`" ,
30+ ) ;
2131 let ast = parse ( source) . unwrap ( ) ;
2232 let target_json = serde_json:: to_string_pretty ( & ast) . unwrap ( ) ;
2333 let new_path = format ! ( "./tests/fixtures/benches/{}.json" , sample) ;
You can’t perform that action at this time.
0 commit comments