diff --git a/README.md b/README.md index 28960fc6..bb172de4 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,53 @@ # ๐Ÿš€ A Blazingly Fast Salesforce Apex Formatter -Afmt is a **Salesforce Apex Code Formatter** written in **Rust**! This tool formats your Apex code for consistency and readability. ๐ŸŽฏ It uses [tree-sitter apex parser](https://github.com/aheber/tree-sitter-sfapex) to traverse AST nodes. +Afmt is written in **Rust** ๐Ÿฆ€. +It uses [tree-sitter apex parser](https://github.com/aheber/tree-sitter-sfapex) to traverse AST nodes. -Note: This is a project in its early phase, don't expect to use it in production code yet. -Project Project can be found in this section. +Note: This is a project in its early phase, don't expect to use it in production code yet. +Project progress can be found below. # ๐Ÿ”ง Usage Download the binary from the [release page](https://github.com/xixiaofinland/afmt/releases). It supports Linux, MacOS, and Linux. -Run `afmt -h` to check the supported parameters. +Extract and run `afmt -h` to check the supported parameters. + +``` +Format Apex file v0.0.7 + +Usage: afmt [OPTIONS] + +Options: + -f, --file The relative path to the file to parse [default: test.cls] + -c, --config Path to the .afmt.toml configuration file + -w, --write Write the formatted result back to the file + -h, --help Print help + -V, --version Print version +``` ## Simplest use scenario: -- create a `test.cls` file next to binary +- create a `test.cls` file next to binary with Apex code - run `afmt` to dry-check the format result -- run `afmt -w` to write the format result back to `test.cls` +- run `afmt -w` to write the format result into the file (`test.cls`) + +``` +ยป afmt +Result 0: Ok +public class Me { + public integer prop { get; set { + prop = value; + } } +} + +Formatted content written back to: test.cls + +Afmt completed successfully. + +Execution time: 995.869โ”ฌโ•กs +```
# ๐Ÿ“Ÿ Project Progress diff --git a/src/args.rs b/src/args.rs index 0352929a..ed074e75 100644 --- a/src/args.rs +++ b/src/args.rs @@ -43,6 +43,6 @@ pub fn get_args() -> Args { .expect("File path is required") .to_string(), config: matches.get_one::("config").map(|s| s.to_string()), - write: matches.contains_id("write"), + write: matches.get_flag("write"), } } diff --git a/src/main.rs b/src/main.rs index d98a95fe..47c56c8c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,6 +30,7 @@ fn main() { } fn run(args: Args) -> Result<()> { + eprintln!("gopro[5]: main.rs:32: args={:#?}", args); let session = Session::create_session_from_config(args.config.as_deref(), vec![args.path.clone()])?; let results = format(session);