Added argparse to simplify bash scripts - #156
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a comprehensive argument parsing library (argparse.bash) to standardize command-line argument handling across all bash scripts in the AlkOS project, replacing custom parsing logic with a unified system.
Key changes:
- Added a new argparse library providing standardized argument parsing functionality
- Refactored all scripts to use the new argparse system instead of custom parsing logic
- Updated error handling to use consistent help message patterns
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/utils/argparse.bash | New comprehensive argument parsing library with support for options, positionals, flags, and help generation |
| scripts/utils/helpers.bash | Updated error handling to provide usage information hint |
| scripts/tests/regression/*.bash | Migrated to use argparse for consistent argument handling |
| scripts/install/*.bash | Replaced custom parsing logic with argparse implementation |
| scripts/env/*.bash | Standardized argument parsing across environment setup scripts |
| scripts/config/configure.bash | Refactored to use argparse with improved help system |
| scripts/alkos_cli.bash | Updated main CLI to use new argument parsing system |
|
LGTM, only issue I have is that if you want to change a flag (like p|preset) into (P|preset) current code requires changing every single line that includes argparse_get. As scripts grow it's common to have to change those flags due to name collisions (like -c for compile, -C for clean, -c for configure etc, this is something that we can expect to have to change in scripts). Can be resolved with simple variable assignment. Or maybe argparser could dynamically declare variables for use in script, like automatically declare ARGPARSER_PRESET if its parsed? I dont know whats best, both options viable and i trust you pick and find the best solution. |
Things done in this PR: - introduced simple argparse functionality to bash utils - refactored all scripts using arguments parsing --------- Co-authored-by: Adam Ogieniewski <ogieniewski.dev@gmail.com>
Things done in this PR: