Skip to content

Commit

Permalink
Merge pull request #1323 from kopackiw/issue-1272
Browse files Browse the repository at this point in the history
Turn the "--models" CLI option into an argument
  • Loading branch information
hannobraun authored Nov 8, 2022
2 parents 6d0a1d0 + 0f65994 commit 2c8cc2a
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Models are Rust libraries that depend on the [`fj`](https://crates.io/crates/fj)
To view a model, run:

``` sh
fj-app --model my-model
fj-app my-model
```

This will usually compile and load the model in the `my-model/` directory. If there is a configuration file (`fj.toml`) available, it might define a default path to load models from that is different from the current working directory. This is the case [in the Fornjot repository](fj.toml).
Expand All @@ -122,7 +122,7 @@ Toggle model rendering by pressing `1`. Toggle mesh rendering by pressing `2`. T
To export a model to a file, run:

``` sh
fj-app --model my-model --export my-model.3mf
fj-app my-model --export my-model.3mf
```

The file type is chosen based on the file extension. Both 3MF and STL are supported.
Expand All @@ -132,7 +132,7 @@ The file type is chosen based on the file extension. Both 3MF and STL are suppor
Models can define parameters that can be overridden. This can be done using the `--parameters` argument:

``` sh
fj-app --model my-model --parameters "width=3.0,height=5.0"
fj-app my-model --parameters "width=3.0,height=5.0"
```


Expand Down
1 change: 0 additions & 1 deletion crates/fj-app/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use fj_math::Scalar;
#[command(version = fj::version::VERSION_FULL)]
pub struct Args {
/// The model to open
#[arg(short, long)]
pub model: Option<PathBuf>,

/// Export model to this path
Expand Down
6 changes: 3 additions & 3 deletions fj.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# The default path that models are loaded from. If the `--model` argument is a
# The default path that models are loaded from. If the `model` argument is a
# relative path, it is assumed to be relative to `default_path`.
default_path = "models"

# The default models that is loaded, if none is specified. If this is a relative
# path, it should be relative to `default_path`.
# The default models that is loaded, if none is specified in a CLI.
# If this is a relative path, it should be relative to `default_path`.
default_model = "test"

# Indicate whether to invert the zoom direction. Can be used to override the
Expand Down
2 changes: 1 addition & 1 deletion models/cuboid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A model of a simple cuboid that demonstrates sweeping a 3D shape from a primitiv

To display this model, run the following from the repository root (model parameters are optional):
``` sh
cargo run -- --model cuboid --parameters x=3.0,y=2.0,z=1.0
cargo run -- cuboid --parameters x=3.0,y=2.0,z=1.0
```

![Screenshot of the cuboid model](cuboid.png)
2 changes: 1 addition & 1 deletion models/spacer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A simple spacer model that demonstrates the circle primitive, the difference ope

To display this model, run the following from the repository root (model parameters are optional):
``` sh
cargo run -- --model spacer --parameters outer=1.0,inner=0.5,height=1.0
cargo run -- spacer --parameters outer=1.0,inner=0.5,height=1.0
```

![Screenshot of the spacer model](spacer.png)
2 changes: 1 addition & 1 deletion models/star/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A model of a star that demonstrates sweeping a sketch to create a 3D shape, conc

To display this model, run the following from the repository root (model parameters are optional):
``` sh
cargo run -- --model star --parameters num_points=5,r1=1.0,r2=2.0,h=1.0
cargo run -- star --parameters num_points=5,r1=1.0,r2=2.0,h=1.0
```

![Screenshot of the star model](star.png)
2 changes: 1 addition & 1 deletion models/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A model that tries to use all of Fornjot's features, to serve as a testing groun

To display this model, run the following from the repository root:
``` sh
cargo run -- --model test
cargo run -- test
```

![Screenshot of the test model](test.png)
2 changes: 1 addition & 1 deletion tools/export-validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn main() -> anyhow::Result<()> {
let exit_status = Command::new("cargo")
.arg("run")
.arg("--")
.args(["--model", &model])
.arg(&model)
.args(["--export", export_file_path_str])
.status()?;

Expand Down

0 comments on commit 2c8cc2a

Please sign in to comment.