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

CLI: Implement new command 'open-step' #1222

Merged
merged 2 commits into from Sep 4, 2023
Merged

CLI: Implement new command 'open-step' #1222

merged 2 commits into from Sep 4, 2023

Conversation

ubruhin
Copy link
Member

@ubruhin ubruhin commented Aug 31, 2023

Add a new CLI command to minify and validate individual STEP files without requiring to open a whole LibrePCB library. This is intended mainly for librepcb-parts-generator to post-process generated STEP files.

Usage

Usage: ./librepcb-cli [options] open-step [command_options] file
LibrePCB Command Line Interface

Options:
  -h, --help        Print this message.
  -V, --version     Displays version information.
  -v, --verbose     Verbose output.
  --minify          Minify the STEP model before validating it. Use in
                    conjunction with '--save-to' to save the output of the
                    operation.
  --tesselate       Tesselate the loaded STEP model to check if LibrePCB is
                    able to render it. Reports failure (exit code = 1) if no
                    content is detected.
  --save-to <file>  Write the (modified) STEP file to this output location (may
                    be equal to the opened file path). Only makes sense in
                    conjunction with '--minify'.

Arguments:
  open-step         Open a STEP model to execute STEP-related tasks outside of
                    a library.
  file              Path to the STEP file (*.step).

Example

$ librepcb-cli open-step --minify --tesselate --save-to=minified.step model.step
Open STEP file 'model.step'...
Perform minify...
 - Minified from 138,951 bytes to 54,462 bytes (-61%)
Save to 'minified.step'...
Load model...
Tesselate model...
 - Built 6360 vertices with 1 different colors
SUCCESS

@dbrgn Maybe you like to take a look at this API before it gets released(?)

@ubruhin ubruhin added enhancement tool-cli Issues affecting librepcb-cli labels Aug 31, 2023
@ubruhin ubruhin added this to the 1.0.0 milestone Aug 31, 2023
@ubruhin ubruhin self-assigned this Aug 31, 2023
@dbrgn
Copy link
Member

dbrgn commented Sep 2, 2023

I wonder if it makes sense to have separate flags for --minify and --save-to, given that "[save-to] only makes sense in conjunction with '--minify'".

However, there might be other modification commands in the future, so it is probably good as-is.

@ubruhin
Copy link
Member Author

ubruhin commented Sep 2, 2023

However, there might be other modification commands in the future, so it is probably good as-is.

That was exactly my idea behind this concept 🙂

EDIT: An alternative would be to replace --save-to=<file> by just --save as we already have for the open-project and open-library commands, but I thought when modifying standalone files (like STEP) one might keep the original as-is.

@ubruhin ubruhin merged commit 69871aa into master Sep 4, 2023
8 checks passed
@ubruhin ubruhin deleted the cli-minify-step branch September 4, 2023 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement tool-cli Issues affecting librepcb-cli
Development

Successfully merging this pull request may close these issues.

None yet

2 participants