Update README.md

- add more usage examples
This commit is contained in:
Pakin 2025-10-16 15:56:46 +07:00
parent 93c9a9fc54
commit a15f0d42f9

View file

@ -41,4 +41,50 @@ let mys_recipe_model = common::create_recipe_model_from_file(common::create_reci
... ...
``` ```
...WIP ### Get list of material settings
```rust
// get current material settings including empty (0)
let mut used_in_mys = mys_recipe_model.list_material_settings();
used_in_mys.push("0".to_string());
```
### Get all recipe of expected material id
```rust
let aus_latest = common::create_recipe_model_from_file(common::create_recipe_path(
"aus",
*aus_version.unwrap(),
));
let prod_list = aus_latest.find_recipe_by_material_path_id("511214");
```
### Generate google sheet style table of recipe from file
```rust
// Experimental: expect current execution path to have `./test_result` folder first, and `config.RECIPE_DIR/{country}/{version_file_format}` must exist.
import::generate_recipe_sheet_table("mys", 626);
```
### Notes
Simple Snippet Patterns
```rust
// =============================================
// Get current material and convert to thai id
// =============================================
let curr_rpl_mat_id = rpl.materialPathId.as_i64().unwrap_or(0);
// strip off first 2
let pure_mat_id = if curr_rpl_mat_id > 300000 {
//
curr_rpl_mat_id.to_string()[2..]
.parse::<i64>()
.expect("not a number")
} else {
curr_rpl_mat_id
};
```