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

Always require model when starting fj-app #1242

Merged
merged 2 commits into from
Oct 20, 2022
Merged
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
25 changes: 9 additions & 16 deletions crates/fj-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn main() -> anyhow::Result<()> {
{
let mut model_path = path;
model_path.push(model);
Some(Model::from_path(model_path.clone()).with_context(|| {
Model::from_path(model_path.clone()).with_context(|| {
if path_of_model.as_os_str().is_empty() {
format!(
"Model is not defined, can't find model defined inside the default-model also, add model like \n cargo run -- -m {}", model.display()
Expand All @@ -68,21 +68,18 @@ fn main() -> anyhow::Result<()> {
"Failed to load model: {0}\ninside default models directory: '{1}'\nCan mainly caused by: \n1. Model '{2}' can not be found inside '{1}'\n2.'{2}' can be mis-typed see inside '{1}' for a match\n3. Define model is '{2}' couldn\'t be found ((defined in command-line arguments))", model_path.display(), path_of_model.display(), model.display()
)
}
})?)
})?
} else {
None
return Err(anyhow!(
"You must specify a model to start Fornjot.\n\
- Pass a model as a command-line argument. See `fj-app --help`.\n\
- Specify a default model in the configuration file."
));
};

if let Some(export_path) = args.export {
// export only mode. just load model, process, export and exit

let model = model.ok_or_else(|| {
anyhow!(
"No model specified, and no default model configured.\n\
Specify a model by passing `--model path/to/model`."
)
})?;

let shape = model.load_once(&parameters, &mut status)?;
let shape = shape_processor.process(&shape)?;

Expand All @@ -93,12 +90,8 @@ fn main() -> anyhow::Result<()> {

let invert_zoom = config.invert_zoom.unwrap_or(false);

if let Some(model) = model {
let watcher = model.load_and_watch(parameters)?;
run(Some(watcher), shape_processor, status, invert_zoom)?;
} else {
run(None, shape_processor, status, invert_zoom)?;
}
let watcher = model.load_and_watch(parameters)?;
run(Some(watcher), shape_processor, status, invert_zoom)?;

Ok(())
}