Skip to content

Commit 34e642c

Browse files
Merge pull request #366 from code0-tech/#362-create-fn-def-automatically
create publish command in cli
2 parents db9e469 + b185449 commit 34e642c

121 files changed

Lines changed: 351 additions & 7763 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,27 @@ jobs:
1616
- name: Checkout Code
1717
uses: actions/checkout@v7
1818

19-
- name: Set script permissions
20-
run: chmod +x ./scripts/inject-version.sh
19+
- name: Install Rust toolchain
20+
uses: dtolnay/rust-toolchain@stable
2121

22-
- name: Inject version
22+
- name: Cache cargo registry
23+
uses: actions/cache@v5
24+
with:
25+
path: |
26+
~/.cargo/registry
27+
~/.cargo/git
28+
target
29+
key: ${{ runner.os }}-cargo-publish-definitions-${{ hashFiles('**/Cargo.lock') }}
30+
restore-keys: |
31+
${{ runner.os }}-cargo-
32+
33+
- name: Generate published definitions
2334
run: |
2435
VERSION="${{ github.ref_name }}"
2536
VERSION="${VERSION#*-}" # removes everything up to the first dash
26-
./scripts/inject-version.sh "$VERSION"
37+
cargo run -- publish --version "$VERSION" --path definitions --out out
38+
rm -rf definitions
39+
mv out definitions
2740
2841
- name: Archive definitions folder
2942
run: |

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ reader/ts/build
77
bundles
88
reader/**/*.js
99
*.d.ts
10-
**/dist
10+
**/dist
11+
/out

README.md

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,92 @@ This repository contains all definitions for Code0. These definitions will be us
44
## Definition CLI
55

66
### Setup
7-
First download cargo to use the cli.
7+
First install Cargo to use the CLI.
88
[Install Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html)
99

1010
Then run:
1111
```bash
1212
cargo install code0-cli
1313
```
1414

15-
After the cli compiled succesfully you can use it via:
15+
After the CLI compiles successfully, use it via:
1616
```bash
1717
code0-cli
1818
```
1919

2020
### Usage
21-
(Stay inside the root directory when running the command)
21+
Stay inside the repository root when running commands against the local `definitions` folder. Most commands use `./definitions` by default.
2222

2323
#### Download
24-
Will download the latest Definitions from the Code0 Definition Repository.
24+
Downloads `definitions.zip` from the Code0 definition GitHub releases and extracts it into `./definitions`.
2525

26-
If no feature is specified, all features will be downloaded. If a feature is specified, only that feature will be kept & can be loaded by one of the following languages: TypeScript, Rust.
27-
28-
-f (--features) is a list of features that will be downloaded.
29-
-t (--tag) is the version tag of the release you want to select.
26+
-t (--tag) selects a specific release tag.
27+
-f (--features) keeps only the listed extracted definition folders.
3028

3129
```bash
3230
code0-cli download
3331
code0-cli download -t def-0.0.8
34-
code0-cli download -f feature_1 feature_2 feature_3
35-
code0-cli download -t def-0.0.8 -f feature_1 feature_2 feature_3
32+
code0-cli download -f taurus-number taurus-text
33+
code0-cli download -t def-0.0.8 -f taurus-number taurus-text
3634
```
3735

38-
#### General Report
39-
Will create a report of all errors in the definitions.
36+
#### Report
37+
Validates the definitions and prints a summary report.
4038

4139
```bash
4240
code0-cli report
4341
code0-cli report -p /path/to/definitions
4442
```
4543

46-
#### Feature Report
47-
Will create a report of all errors in the definitions for a specific feature. Will also report on all specified functions, data types, and flow types.
44+
#### Module
45+
Prints definition details for all modules, or for one module by identifier.
4846

4947
```bash
50-
code0-cli feature
51-
code0-cli feature -p /path/to/definitions
52-
code0-cli feature -f feature_name
53-
code0-cli feature -f feature_name -p /path/to/definitions
48+
code0-cli module
49+
code0-cli module -n taurus-number
50+
code0-cli module -p /path/to/definitions
51+
code0-cli module -n taurus-number -p /path/to/definitions
5452
```
5553

5654
#### Watch for Changes
57-
Will run the report each time a definition file changes.
55+
Runs the analyser whenever a definition file changes.
5856

5957
```bash
6058
code0-cli watch
6159
code0-cli watch -p /path/to/definitions
60+
code0-cli watch --ignore-warnings
61+
```
62+
63+
#### Search
64+
Searches for a specific definition by identifier or runtime name and prints the matching JSON.
65+
66+
```bash
67+
code0-cli search -n std::number::add
68+
code0-cli search -n std::number::add -p /path/to/definitions
69+
```
70+
71+
#### Publish
72+
Generates publishable definitions from the source definitions. By default, it reads from `./definitions` and writes to `./out`.
73+
74+
```bash
75+
code0-cli publish -v 0.0.8
76+
code0-cli publish -v 0.0.8 -p /path/to/definitions
77+
code0-cli publish -v 0.0.8 -p /path/to/definitions -o /path/to/out
6278
```
6379

64-
#### Definition
65-
Will search for a specific definition.
80+
To replace the source folder with the generated output, use:
6681

6782
```bash
68-
code0-cli definition -n definition_name
69-
code0-cli definition -n definition_name -p /path/to/definitions
83+
code0-cli publish -v 0.0.8 --path definitions --out out
84+
rm -rf definitions
85+
mv out definitions
7086
```
7187

88+
#### Push
89+
Pushes definitions to a Sagittarius endpoint.
90+
91+
```bash
92+
code0-cli push -t "$SAGITTARIUS_TOKEN" -u "https://sagittarius.example.com"
93+
code0-cli push -t "$SAGITTARIUS_TOKEN" -u "https://sagittarius.example.com" -v 0.0.8
94+
code0-cli push -t "$SAGITTARIUS_TOKEN" -u "https://sagittarius.example.com" -p /path/to/definitions
95+
```

crates/cli/src/command/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pub mod download;
22
pub mod parse_errors;
3+
pub mod publish;
34
pub mod push;
45
pub mod report;
56
pub mod search;

0 commit comments

Comments
 (0)