Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors argument parsing across shell scripts by moving argument handling from inside the main() function to the top-level script scope, and enhances user experience with help documentation.
Key changes:
- Moved argument parsing from inside
main()to top-level script scope usingwhile [ $# -gt 0 ]loops - Added
_usage_help()functions with formatted help documentation and examples - Separated argument validation logic into dedicated sections with clear comment markers
- Removed arguments from
mainfunction calls (changed frommain "${@:-}"tomain)
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/release.sh | Removed arguments from main function call (no argument parsing in this script) |
| scripts/docs.sh | Refactored argument parsing to top-level, added help function with examples, separated validation logic |
| scripts/clean.sh | Refactored argument parsing to top-level, added help function with examples |
| scripts/changelog.sh | Refactored argument parsing to top-level, added help function with examples, separated validation logic |
| scripts/bump-version.sh | Refactored argument parsing to top-level, added help function with examples, separated validation logic, added support for space-separated argument values |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| while [ $# -gt 0 ]; do | ||
| case "${1}" in | ||
| -b | --bump | --bump-type) | ||
| [ $# -ge 2 ] || { echo "[ERROR]: ${1} requires a value!" >&2; exit 1; } |
There was a problem hiding this comment.
The argument parsing for -b | --bump | --bump-type now accepts space-separated values, but the error message at line 79 still instructs users to use the equals sign format (-b= or --bump-type=). Update the error message to reflect that both formats are now supported (e.g., -b patch or --bump-type=patch).
| [ $# -ge 2 ] || { echo "[ERROR]: ${1} requires a value!" >&2; exit 1; } | |
| [ $# -ge 2 ] || { echo "[ERROR]: ${1} requires a value! Usage: -b patch or --bump-type=patch" >&2; exit 1; } |
| [ $# -ge 2 ] || { echo "[ERROR]: ${1} requires a value!" >&2; exit 1; } | ||
| _BUMP_TYPE="${2}" | ||
| shift 2;; | ||
| -b=* | --bump=* | --bump-type=*) |
There was a problem hiding this comment.
The --bump=* pattern is not documented in the help text at line 35. Either add --bump to the OPTIONS documentation or remove this case pattern to keep the implementation consistent with the documented interface.
This pull request refactors the argument parsing and help output for several shell scripts, improving usability and consistency. The main changes include replacing custom argument parsing logic with a standardized approach, adding detailed usage/help messages, and cleaning up script entry points.
Argument parsing and help improvements:
while [ $# -gt 0 ]; do ...and added comprehensive_usage_helpfunctions toscripts/bump-version.sh,scripts/changelog.sh,scripts/clean.sh, andscripts/docs.sh. This provides clear usage instructions, options, and examples for each script. [1] [2] [3] [4]Validation and main function cleanup:
gitwhen needed) and moved them outside the main logic for better separation and readability. [1] [2] [3]mainwithout passing arguments, since argument parsing is now handled before the main function. [1] [2] [3] [4] [5]Minor cleanup:
These changes make the scripts easier to use, maintain, and extend, with consistent behavior across the tooling.