Skip to content

Commit ec3a084

Browse files
committed
docs: added package usage to readme
1 parent 5b61b72 commit ec3a084

File tree

2 files changed

+46
-24
lines changed

2 files changed

+46
-24
lines changed

README.md

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,55 @@
1-
# Definition CLI
1+
# Definitions
22

3-
## Setup
4-
```bash
5-
cargo build --release
6-
```
3+
## Definition CLI
74

8-
## Usage
5+
### Setup
6+
[Install Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html)
97

8+
### Usage
9+
(Stay inside the root directory when running the command)
1010
### General Report
1111
```bash
12-
./cli report
13-
./cli report -p /path/to/definitions
12+
./cargo run report
13+
./cargo run report -p /path/to/definitions
1414
```
1515

1616
### Feature Report
1717
```bash
18-
./cli feature
19-
./cli feature -f feature_name
20-
./cli feature -f feature_name -p /path/to/definitions
18+
./cargo run feature
19+
./cargo run feature -p /path/to/definitions
20+
./cargo run feature -f feature_name
21+
./cargo run feature -f feature_name -p /path/to/definitions
2122
```
2223

2324
### Watch for Changes
2425
```bash
25-
./cli watch
26-
./cli watch -p /path/to/definitions
26+
./cargo run watch
27+
./cargo run watch -p /path/to/definitions
2728
```
2829

2930
### Definition
3031
```bash
31-
./cli definition -n definition_name
32-
./cli definition -n definition_name -p /path/to/definitions
32+
./cargo run definition -n definition_name
33+
./cargo run definition -n definition_name -p /path/to/definitions
34+
```
35+
36+
## TypeScript Definition Package
37+
38+
### Install Package
39+
```bash
40+
npm i @code0-tech/code0-definition-reader --save-dev
3341
```
42+
43+
### Usage
44+
45+
```ts
46+
const features = Definition("./path/to/definitions")
47+
48+
for (const feature in features) {
49+
const name = feature.name; //name of the feature (e.g. rest)
50+
const dataTypes = fearture.dataTypes; //dataTypes of this feature
51+
const flowTypes = fearture.flowTypes; //flowTypes of this feature
52+
const functions = fearture.runtimeFunctions; //runtimeFunctions of this feature
53+
}
54+
```
55+

reader/ts/src/parser.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import {DataType, FlowType, RuntimeFunctionDefinition} from "@code0-tech/sagitta
33

44
export interface Feature {
55
name: string;
6-
data_types: DataType[];
7-
flow_types: FlowType[];
8-
runtime_functions: RuntimeFunctionDefinition[];
6+
dataTypes: DataType[];
7+
flowTypes: FlowType[];
8+
runtimeFunctions: RuntimeFunctionDefinition[];
99
}
1010

1111
export const Definition = (rootPath: string): Feature[] => {
@@ -21,9 +21,9 @@ export const Definition = (rootPath: string): Feature[] => {
2121
} else {
2222
feature = {
2323
name: m.name,
24-
data_types: [],
25-
flow_types: [],
26-
runtime_functions: [],
24+
dataTypes: [],
25+
flowTypes: [],
26+
runtimeFunctions: [],
2727
};
2828
appendMeta(feature, m);
2929
features.push(feature);
@@ -39,17 +39,17 @@ function appendMeta(feature: Feature, meta: Meta): void {
3939
switch (meta.type) {
4040
case MetaType.DataType: {
4141
const parsed = JSON.parse(definition) as DataType;
42-
feature.data_types.push(parsed);
42+
feature.dataTypes.push(parsed);
4343
break;
4444
}
4545
case MetaType.FlowType: {
4646
const parsed = JSON.parse(definition) as FlowType;
47-
feature.flow_types.push(parsed);
47+
feature.flowTypes.push(parsed);
4848
break;
4949
}
5050
case MetaType.RuntimeFunction: {
5151
const parsed = JSON.parse(definition) as RuntimeFunctionDefinition;
52-
feature.runtime_functions.push(parsed);
52+
feature.runtimeFunctions.push(parsed);
5353
break;
5454
}
5555
}

0 commit comments

Comments
 (0)