Skip to content

feat: add install action for dependencies and bash completion - #23

Merged
pforret merged 1 commit into
masterfrom
claude/bashew-install-action-r4ogbl
Aug 24, 2026
Merged

feat: add install action for dependencies and bash completion#23
pforret merged 1 commit into
masterfrom
claude/bashew-install-action-r4ogbl

Conversation

@pforret

@pforret pforret commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Adds an install verb to the generated scripts, next to the existing check, env and update verbs.

  • Adds install action that handles dependency checking and bash/zsh completion setup
  • Parses Os:require calls to find dependencies
  • Skips symlink step if installed via basher
  • Auto-generates completion from Option:config

What it does

$script_prefix install runs three steps, each one asking for confirmation (or skipping the question with -f/--FORCE), and all three are idempotent:

  1. requirementsScript:list_requirements greps the real Os:require calls out of the script (comments and the documentation header are ignored) and turns them into <binary><tab><install hint>. Every missing binary is offered for installation, using the same logic as Os:require: the install hint of the call, or the package manager detected in Script:meta (brew install, apt install, apk add, …).
  2. symlink — links the script into the first writable folder of $HOME/.local/bin, $HOME/bin, /usr/local/bin (offering to create $HOME/.local/bin if none exists, and warning when it is not in $PATH). Skipped when the script lives under .basher/ or $BASHER_ROOT, because basher already creates that link.
  3. completionScript:completion generates a bash/zsh completion script from Option:config() (short + long names of flags/options/lists, plus all values of the choice line) into ~/.bash_completion.d/<script>, and activates it in ~/.bashrc and ~/.zshrc (with bashcompinit for zsh). Startup files that do not exist are left alone.

Os:require no longer dies during the install action, otherwise a script with a missing dependency would exit before Script:install could offer to install it. All other actions keep the current behaviour.

Also included: a stray , flazg_set fragment on line 270 of bashew.sh (introduced in 61ac1c0) made bashew check print line 270: ,: command not found and made shellcheck fail on the repo root, so it is removed here.

Test plan

  • shellcheck bashew.sh template/script.sh — clean
  • bash_unit tests/test_* — all bashew tests pass (test_slugify fails identically before and after this change, it needs the en_US.UTF-8 locale)
  • generated a script with bashew.sh script and ran install: dependency check, symlink creation, completion file, .bashrc/.zshrc activation, and a second run that correctly reports everything as already installed
  • verified the generated completion function completes both --options and the action choices
  • verified the symlink step is skipped for a script under .basher/ and under $BASHER_ROOT
  • verified missing dependencies are reported with the right install instructions instead of killing the script

Generated by Claude Code

Generated scripts now have an `install` verb next to check/env/update:

- Script:install_requirements parses the Os:require calls in the script
  and offers to install every missing binary with the package manager
  detected in Script:meta (or the install hint of the Os:require call)
- Script:install_symlink links the script into the first writable folder
  of $HOME/.local/bin, $HOME/bin or /usr/local/bin - this step is skipped
  when the script was installed with basher, which already does this
- Script:install_completion generates a bash/zsh completion script from
  Option:config (flags, options and choice values) and activates it in
  ~/.bashrc and ~/.zshrc

All steps ask for confirmation (unless -f/--FORCE) and are idempotent.
Os:require no longer dies during the install action, so the install verb
can actually fix the missing binaries it reports.

Also fixes a stray "flazg_set" fragment in bashew.sh that made
`bashew check` print a "command not found" error and broke shellcheck.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013CTqVsScAVUbkTAQB9gMyA
@what-the-diff

what-the-diff Bot commented Aug 20, 2026

Copy link
Copy Markdown

PR Summary

  • Built-in Actions Documentation Addition
    The team has included additional information in the document, CLAUDE.md, clarifying four specific actions that help scripts perform various tasks effectively. These tasks involve checking for conditions, interacting with the environment, software installation, and updating mechanisms.

  • Improved Action Handling in bashew.sh
    The bashew.sh script has been updated to handle actions more efficiently, specifically the 'check' action meant for verifying certain conditions before a script proceeds.

  • Better Script Template for Guidance
    The script templates have been made more user-friendly by including detailed descriptions of new built-in operations like checking conditions, environment interactions, software installation, and updates in the comments section.

  • Implementation of Install Action in Main Script
    Now, the main script supports a new 'install' action which helps to set up all necessary installations, links and other features that allow the script to execute smoothly.

  • Detailed Functionality for Installation Procedures
    The PR includes functions that handle the installation of required software, setting up shortcuts, implementing shell completions, and handling start-up scenarios more efficiently.

  • Ability to Generate Completion Script
    One can now generate a script that completes tasks based on flags, options, and choices inherent in the script. This feature imparts flexibility to users and increases project efficiency.

@pforret
pforret merged commit 479a895 into master Aug 24, 2026
3 checks passed
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.

2 participants