Skip to content

Added argparse to simplify bash scripts - #156

Merged
Jlisowskyy merged 151 commits into
devfrom
Jlisowskyy/ArgParse
Aug 8, 2025
Merged

Jlisowskyy merged 151 commits into
devfrom
Jlisowskyy/ArgParse

Conversation

@Jlisowskyy

Copy link
Copy Markdown
Member

Things done in this PR:

  • introduced simple argparse functionality to bash utils
  • refactored all scripts using arguments parsing

Copilot AI review requested due to automatic review settings August 3, 2025 14:03

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Comment thread scripts/utils/argparse.bash
Comment thread scripts/utils/argparse.bash
Comment thread scripts/utils/argparse.bash
Comment thread scripts/utils/argparse.bash
Comment thread scripts/utils/argparse.bash
Comment thread scripts/env/install_deps_arch.bash
Comment thread scripts/env/clean_build_dir.bash
Comment thread scripts/env/clean_build_dir.bash
Comment thread scripts/env/clean_build_dir.bash
Comment thread scripts/tests/regression/common/parsing.bash
@kryczkal

kryczkal commented Aug 5, 2025

Copy link
Copy Markdown
Member

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.

Comment thread scripts/config/configure.bash
Comment thread scripts/env/install_toolchain.bash
@Jlisowskyy
Jlisowskyy merged commit b90d896 into dev Aug 8, 2025
3 of 4 checks passed
@Jlisowskyy
Jlisowskyy deleted the Jlisowskyy/ArgParse branch August 8, 2025 00:21
kryczkal pushed a commit that referenced this pull request Oct 22, 2025
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>
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.

3 participants