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

Added CLI Interface #179

Merged
merged 6 commits into from
Dec 5, 2024
Merged

Conversation

Viermusketiere
Copy link
Contributor

I added a CLI interface which enables the plugin to be used standalone on an arbitrary board file.
Reason is that most other JLCPCB scripts available either require a schematic file (which in my case is not available).

No additional dependencies are added.
Changes to existing code have been kept to a bare minimum as the plugin functionality is the main feature.

CLI can simply be used by cloning the repository and running python -m plugins.cli -p [pathToBoardFile].
See python -m plugins.cli --help on how to set all options which are implemented in the GUI menu as command parameters.

python3 -m plugins.cli -h

usage: Fabrication Toolkit [-h] --path PATH [--additionalLayers ADDITIONALLAYERS] [--user1VCut] [--user2AltVCut] [--autoTransitions] [--autoFill] [--excludeDNP] [--openBrowser]

Generates JLCPCB production files from a KiCAD board file

options:
  -h, --help            show this help message and exit
  --path PATH, -p PATH  Path to KiCAD board file
  --additionalLayers ADDITIONALLAYERS, -aL ADDITIONALLAYERS  Additional layers(comma-separated)
  --user1VCut, -u1      Set User.1 as V-Cut layer
  --user2AltVCut, -u2   Use User.2 for alternative Edge-Cut layer
  --autoTransitions, -t    Apply automatic position/rotation translations
  --autoFill, -f        Apply automatic fill for all zones
  --excludeDNP, -e      Exclude DNP components from BOM
  --openBrowser, -b     Open webbrowser with directory file overview after generation

Feel free to make any suggestion on improvements.

Copy link
Owner

@bennymeg bennymeg left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution. Added a couple of suggestions.

plugins/cli.py Outdated
import argparse as ap

from .thread import ProcessThread
from .options import AUTO_FILL_OPT, AUTO_TRANSLATE_OPT, EXCLUDE_DNP_OPT, EXTEND_EDGE_CUT_OPT, ALTERNATIVE_EDGE_CUT_OPT, EXTRA_LAYERS
Copy link
Owner

Choose a reason for hiding this comment

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

In sake of completeness, would you mind adding also 'ALL_ACTIVE_LAYERS_OPT' option? It was added in a recent PR.


def progress(self, percent):
wx.PostEvent(self.wx, StatusEvent(percent))
def cliBar(percent, prefix = '', suffix = '', decimals = 1, length = 100, fill = '█', printEnd = "\r"):
Copy link
Owner

Choose a reason for hiding this comment

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

What do you think about moving this function to the utils module and make it generate the progress bar string instead of printing it. than it can be used in the progress function instead of nesting inside it.

@Viermusketiere
Copy link
Contributor Author

I included your requested changes.
I kept the printing inside the 'print_cli_progress_bar' as custom parameters need to be specified to print and it is easier and cleaner to keep it together inside the function.
Also added documentation to the README for the feature

@bennymeg bennymeg merged commit ff77eca into bennymeg:master Dec 5, 2024
@bennymeg
Copy link
Owner

bennymeg commented Dec 5, 2024

Thank you

bennymeg added a commit that referenced this pull request Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants