Skip to content

Commit 7620ebc

Browse files
authored
Merge pull request #276 from stepchowfun/generate-flags
Rename some flags
2 parents df1fc4a + ad999f9 commit 7620ebc

File tree

8 files changed

+22
-17
lines changed

8 files changed

+22
-17
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.1.0] - 2021-11-08
9+
10+
### Changed
11+
- Renamed `--rust-out` to `--rust` and `--typescript-out` to `--typescript`.
12+
813
## [0.0.7] - 2021-10-25
914

1015
### Fixed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "typical"
3-
version = "0.0.7"
3+
version = "0.1.0"
44
authors = ["Stephan Boyer <[email protected]>"]
55
edition = "2021"
66
description = "Algebraic data types for data interchange."

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Each field also has a type. If the type is missing, as it is for the `success` f
4545
Now that we've defined some types, we can use Typical to generate the code for serialization and deserialization. For example, you can generate Rust code with the following:
4646

4747
```sh
48-
typical generate email_api.t --rust-out email_api.rs
48+
typical generate email_api.t --rust email_api.rs
4949
```
5050

5151
Refer to the [example Rust project](https://github.com/stepchowfun/typical/tree/main/examples/rust) for how to automate this with a [Cargo build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html).
@@ -525,7 +525,7 @@ Notice that several types can take advantage of a more compact representation wh
525525
Once Typical is [installed](#installation-instructions), you can use it to generate code for a schema called `main.t` with the following:
526526

527527
```sh
528-
typical generate main.t --rust-out types.rs --typescript-out types.ts
528+
typical generate main.t --rust types.rs --typescript types.ts
529529
```
530530

531531
Here are the supported command-line options:
@@ -560,8 +560,8 @@ FLAGS:
560560
-h, --help Prints help information
561561
562562
OPTIONS:
563-
--rust-out <PATH> Sets the path of the Rust file to emit
564-
--typescript-out <PATH> Sets the path of the TypeScript file to emit
563+
--rust <PATH> Sets the path of the Rust file to emit
564+
--typescript <PATH> Sets the path of the TypeScript file to emit
565565
566566
ARGS:
567567
<SCHEMA_PATH> Sets the path of the schema

examples/rust/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
let output = Command::new("typical")
1616
.arg("generate")
1717
.arg(SCHEMA_PATH)
18-
.arg("--rust-out")
18+
.arg("--rust")
1919
.arg(Path::new(&out_dir).join("types.rs"))
2020
.output()
2121
.expect("Failed to run Typical. Is it installed?");

integration_tests/rust/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
let output = Command::new("typical")
1616
.arg("generate")
1717
.arg(SCHEMA_PATH)
18-
.arg("--rust-out")
18+
.arg("--rust")
1919
.arg(Path::new(&out_dir).join("types.rs"))
2020
.output()
2121
.expect("Failed to run Typical. Is it installed?");

src/main.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ const BIN_NAME: &str = "typical";
4242
// Command-line option and subcommand names
4343
const GENERATE_SUBCOMMAND: &str = "generate";
4444
const GENERATE_SUBCOMMAND_PATH_OPTION: &str = "generate-path";
45-
const GENERATE_SUBCOMMAND_RUST_OUT_FILE_OPTION: &str = "rust-out";
46-
const GENERATE_SUBCOMMAND_TYPESCRIPT_OUT_FILE_OPTION: &str = "typescript-out";
45+
const GENERATE_SUBCOMMAND_RUST_OPTION: &str = "rust";
46+
const GENERATE_SUBCOMMAND_TYPESCRIPT_OPTION: &str = "typescript";
4747
const SHELL_COMPLETION_SUBCOMMAND: &str = "shell-completion";
4848
const SHELL_COMPLETION_SUBCOMMAND_SHELL_OPTION: &str = "shell-completion-shell";
4949

@@ -69,15 +69,15 @@ fn cli<'a, 'b>() -> App<'a, 'b> {
6969
.required(true), // [tag:generate_subcommand_path_required]
7070
)
7171
.arg(
72-
Arg::with_name(GENERATE_SUBCOMMAND_RUST_OUT_FILE_OPTION)
72+
Arg::with_name(GENERATE_SUBCOMMAND_RUST_OPTION)
7373
.value_name("PATH")
74-
.long(GENERATE_SUBCOMMAND_RUST_OUT_FILE_OPTION)
74+
.long(GENERATE_SUBCOMMAND_RUST_OPTION)
7575
.help("Sets the path of the Rust file to emit"),
7676
)
7777
.arg(
78-
Arg::with_name(GENERATE_SUBCOMMAND_TYPESCRIPT_OUT_FILE_OPTION)
78+
Arg::with_name(GENERATE_SUBCOMMAND_TYPESCRIPT_OPTION)
7979
.value_name("PATH")
80-
.long(GENERATE_SUBCOMMAND_TYPESCRIPT_OUT_FILE_OPTION)
80+
.long(GENERATE_SUBCOMMAND_TYPESCRIPT_OPTION)
8181
.help("Sets the path of the TypeScript file to emit"),
8282
),
8383
)
@@ -234,14 +234,14 @@ fn entry() -> Result<(), Error> {
234234
let rust_out = matches
235235
.subcommand_matches(GENERATE_SUBCOMMAND)
236236
.unwrap() // [ref:generate_subcommand]
237-
.value_of(GENERATE_SUBCOMMAND_RUST_OUT_FILE_OPTION)
237+
.value_of(GENERATE_SUBCOMMAND_RUST_OPTION)
238238
.map(Path::new);
239239

240240
// Determine the path to the TypeScript output file, if provided.
241241
let typescript_out = matches
242242
.subcommand_matches(GENERATE_SUBCOMMAND)
243243
.unwrap() // [ref:generate_subcommand]
244-
.value_of(GENERATE_SUBCOMMAND_TYPESCRIPT_OUT_FILE_OPTION)
244+
.value_of(GENERATE_SUBCOMMAND_TYPESCRIPT_OPTION)
245245
.map(Path::new);
246246

247247
// Generate code for the schema.

toast.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ tasks:
170170
command: |
171171
# Run Typical on the integration test scenario.
172172
cargo-offline run generate integration_tests/types/main.t \
173-
--typescript-out integration_tests/typescript/src/types.ts
173+
--typescript integration_tests/typescript/src/types.ts
174174
175175
# Validate the resulting TypeScript code.
176176
(cd integration_tests/typescript && npm run check)

0 commit comments

Comments
 (0)