Skip to content

Commit

Permalink
update readme to reflect justfile changes, fix cargo fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stano45 committed Jul 9, 2023
1 parent a149cad commit e3c3274
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Crustagen is a Rust code generator that takes AsyncAPI specifications as input a
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Limitations](#limitations)
- [Contribute](#contribute)
- [License](#license)

Expand All @@ -25,7 +26,7 @@ Clone and build the Crustagen project:

```sh
git clone https://github.com/Programmierpraktikum-MVA/AsyncAPI.git
cd crustagen
cd AsyncAPI
just install # Alternatively, you can use 'cargo build --release'
```

Expand All @@ -34,30 +35,30 @@ just install # Alternatively, you can use 'cargo build --release'
To generate Rust code from an AsyncAPI specification, use the following `just` command:

```sh
just run-generator specfile_path="./example/specs/basic.yaml" output="./output" # Alternatively, you can use 'cargo run -- -s ./example/specs/basic.yaml -o ./output'
just run example/specs/basic.yaml output # Alternatively, you can use 'cargo run -- -s ./example/specs/basic.yaml -o ./output'
```

This will generate a Rust project in the specified output directory.

To run the server, navigate to the output directory (replace `{project-id}` with the actual project directory name, the title of the spec) and use the `just` command:

```sh
just start-service service_name={project-id} # Alternatively, you can use 'cd output/{project-id} && cargo run'
just start-service {project-id} # Alternatively, you can use 'cd output/{project-id} && cargo run'
```

To view the auto-generated documentation, use the following command:

```sh
just generate-service-docs service_name={project-id} # Alternatively, you can use 'cd output/{project-id} && cargo doc --open'
just service-doc {project-id} # Alternatively, you can use 'cd output/{project-id} && cargo doc --open'
```

Remember to replace `{project-id}` with the actual project directory name.
Remember to replace `{project-id}` with the name of your generated microservice (`title` field from the provided spec).

## Limitations

- only json payloads are currently supported for automatic deserialization
- only one server is currently supported and only nats protocol is supported
- only one message is currently supported per channel, payloads can be choosen freely including anyOf/oneOf/allOf
- Only json payloads are currently supported for automatic deserialization
- Only one server is currently supported and only nats protocol is supported
- Only one message is currently supported per channel, payloads can be choosen freely including anyOf/oneOf/allOf

## Contribute

Expand Down
13 changes: 10 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,23 @@ fn main() {

// make output a compilable project in output_path
cargo_command!("init", "--bin", output_path);
// runs cargo format on path
cargo_command!("fmt", "--", output_path.join("src/main.rs"));
// add dependencies
append_file_to_file(
template_path.join("dependencies.toml"),
output_path.join("Cargo.toml"),
)
.unwrap();

println!("✨ Successfully added dependencies, formatting code...");
// runs cargo format on path
cargo_command!("fmt", "--", output_path.join("src/main.rs"));
// cargo fix, mostly for cleaning unused imports
cargo_command!("fix", "--bin", output_path, "--allow-dirty");
cargo_command!(
"fix",
"--manifest-path",
output_path.join("Cargo.toml"),
"--allow-dirty"
);

if args.doc {
println!("📚 Generating docs...");
Expand Down

0 comments on commit e3c3274

Please sign in to comment.