-
Notifications
You must be signed in to change notification settings - Fork 22
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
refactor(grimshot): modularize and clean up with functional helpers #38
Conversation
- Introduced functional helper methods: `when`, `if_else`, and `any` for cleaner, more maintainable logic. - Refactored conditional handling in `notifyOk`, `notifyError`, and `check` functions to leverage the new helper methods. - Moved usage message printing to a dedicated `printUsageMsg` function. - Extracted subject-specific logic (e.g., area, window, screen) into standalone functions: `selectArea`, `selectWindow`, etc. - Improved error handling by introducing functions like `handleScreenshotSuccess`, `handleScreenshotFailure`, and `handleSaveCopy`. - Reformatted code and improved readability by using consistent formatting for case statements and conditions. This refactor enhances code maintainability by isolating logic into reusable components, improving clarity and simplifying future changes.
Thank you for your work, I will check it when I have some time. |
yes it is a good idea, but I suggest that the functional_helpers file be in a folder called utils or scripts/functions or sth. like that |
I've also another question, I noticed that the grim-completion script is a bash script while the grim script is a Bourne shell script |
grimshot-completion script is added later, and someone could make zsh or fish completion script for grimshot. |
I think modularization is good, but having two files won't be good for this case. Having one script file would be better to install |
- Moved all grim related files to their own directory - Refactored argument parsing into the `parseArgs` function for improved clarity. - Added `handleUnknownSubject` to handle unknown subjects explicitly.
- Introduced `POSITIONAL_ARGS` to collect and reassign positional arguments using `set -- $POSITIONAL_ARGS` after flag parsing, ensuring correct positional argument handling. - Ensured flag parsing (`--notify`, `--cursor`, `--wait`) is processed before positional arguments. - Stored `$1` as `error_message` in `notifyError` to fix incorrect reference during condition evaluation.
I moved all related grimshot files into also for modularity I refactored argument parsing into it's own func. and added some fixes |
@OctopusET Any update about this PR? |
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.
LGTM
Sorry for delay! @Qubut |
when
,if_else
, andany
for cleaner, more maintainable logic.notifyOk
,notifyError
, andcheck
functions to leverage the new helper methods.printUsageMsg
function.selectArea
,selectWindow
, etc.handleScreenshotSuccess
,handleScreenshotFailure
, andhandleSaveCopy
.This refactor enhances code maintainability by isolating logic into reusable components, improving clarity and simplifying future changes.