Skip to content

Commit 6aa2735

Browse files
committed
[ref] Update Readme
1 parent 5c41ab3 commit 6aa2735

File tree

1 file changed

+57
-14
lines changed

1 file changed

+57
-14
lines changed

README.md

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,26 +98,69 @@ Crate: [code0-definition-reader](https://crates.io/crates/code0-definition-reade
9898
cargo add code0-definition-reader
9999
```
100100

101-
### Usage
101+
### Basic Usage
102102

103103
```rs
104104
use code0_definition_reader::Reader;
105105

106-
let reader = Reader::configure(
107-
String::new(), // Path required for configure
108-
false, // should_break
109-
Vec::new(), // accepted_features
110-
None // accepted_versions
111-
);
106+
fn main() {
107+
// Create a reader with default configuration
108+
let reader = Reader::configure(
109+
"./path/to/definitions".to_string(), // Path to definitions directory
110+
false, // should_break: continue on errors
111+
Vec::new(), // accepted_features: empty = all features
112+
None // accepted_version: None = all versions
113+
);
114+
115+
// Read all features
116+
match reader.read_features() {
117+
Ok(features) => {
118+
for feature in features {
119+
println!("Loaded feature: {}", feature.name);
120+
println!(" - Data Types: {}", feature.data_types.len());
121+
println!(" - Flow Types: {}", feature.flow_types.len());
122+
println!(" - Functions: {}", feature.functions.len());
123+
}
124+
}
125+
Err(err) => {
126+
eprintln!("Failed to read features: {:?}", err);
127+
}
128+
}
129+
}
130+
```
131+
132+
### Advanced Usage - Filter Specific Features
133+
134+
```rs
135+
use code0_definition_reader::Reader;
112136

113-
let features = reader.read_features("./path/to/definitions");
137+
fn main() {
138+
let reader = Reader::configure(
139+
"./definitions".to_string(),
140+
false,
141+
vec!["http".to_string(), "database".to_string()], // Only load http and database features
142+
None
143+
);
114144

115-
for feature in features {
116-
let name = &feature.name; // name of the feature (e.g., http)
117-
let data_types = &feature.data_types; // dataTypes of this feature
118-
let flow_types = &feature.flow_types; // flowTypes of this feature
119-
let functions = &feature.functions; // runtimeFunctions of this feature
145+
let features = reader.read_features().expect("Failed to read features");
120146

121-
println!("Loaded feature: {}", name);
147+
for feature in features {
148+
println!("Feature: {}", feature.name);
149+
150+
// Access data types
151+
for data_type in &feature.data_types {
152+
println!(" DataType: {}", data_type.identifier);
153+
}
154+
155+
// Access flow types
156+
for flow_type in &feature.flow_types {
157+
println!(" FlowType: {}", flow_type.identifier);
158+
}
159+
160+
// Access runtime functions
161+
for function in &feature.functions {
162+
println!(" Function: {}", function.runtime_name);
163+
}
164+
}
122165
}
123166
```

0 commit comments

Comments
 (0)