Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn the "--models" CLI option into an argument #1323

Merged
merged 2 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question to consider: should we uppercase any names of CLI arguments used in the documentation (as it is formatted now in help)?

Screenshot 2022-11-07 at 23 54 35

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Yes, I think we should.

(Still going to merge this as-is though. This is not critical and can always be done in a follow-up PR.)

# 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