-
Notifications
You must be signed in to change notification settings - Fork 27
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 args and help #79
base: main
Are you sure you want to change the base?
added cli args and help #79
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've always felt that this was needed. Tested, working well. I've nitpicked a couple of details for optional changes but other than that, I think this will be helpful.
main(gCodeFileStream,path2GCode, skipInput) | ||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser(description="Process G-code files.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This description is vague and maybe a little lazy. Maybe something like "Process overhangs within PrusaSlicer G-code files into circular arcs." would be clearer.
@@ -37,6 +37,7 @@ | |||
import platform | |||
#from hilbertcurve.hilbertcurve import HilbertCurve | |||
from hilbert import decode, encode | |||
import argparse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just nitpicking here: I think this would make more sense so import on line 29, after os
.
Also moved argparse import to be near other built ins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested in command line and PrusaSlicer. Working, approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failed to remember that I had to edit the getFileStreamAndPath
method!
the new code:
def getFileStreamAndPath(path, read=True):
try:
if read:
f = open(path, "r")
else:
f=open(path, "w")
return f,path
except IOError:
input("File not found.Press enter.")
sys.exit(1)
I tried running a branch of JP's code and could get it to work like mine. Comparing to my dev branch, I couldn't see any big differences. Couldn't figure it out until I compared my local code. Yikes!
Description:
This pull request integrates argument parsing into the G-code processing script, making it more user-friendly and adaptable for automation. It adds support for a mandatory file path as a positional argument and an optional --skip-input flag for non-interactive environments.
Key Changes:
Positional Argument: Users must specify the G-code file path directly when executing the script.
Optional Flag: The --skip-input flag allows users to bypass manual input prompts.
Help Output: Enhanced help documentation is available to assist with new command-line options.
Behavior:
Running with Arguments: python prusa_slicer_post_processing_script.py /path/to/your/file.gcode
Skipping Input Prompts: python prusa_slicer_post_processing_script.py /path/to/your/file.gcode --skip-input
Accessing Help: python prusa_slicer_post_processing_script.py --help
No Arguments Provided: If the script is run without any arguments, it will display an error message and the usage information to help guide the user on how to properly execute the script.