|
| 1 | +# install-cli-tools.sh |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Install common DevOps CLI tooling using the host package manager with repeatable, scriptable behavior. |
| 5 | + |
| 6 | +## Location |
| 7 | +`setup/local/install-cli-tools.sh` |
| 8 | + |
| 9 | +## Preconditions |
| 10 | +- Required tools: `bash`, selected package manager (`brew`, `apt-get`, `dnf`, or `yum`), optional `sudo` |
| 11 | +- Required permissions: package-install privileges on workstation |
| 12 | +- Required environment variables: none |
| 13 | + |
| 14 | +## Arguments |
| 15 | +| Flag | Required | Default | Description | |
| 16 | +|------|----------|---------|-------------| |
| 17 | +| `--tools CSV` | No | built-in tool set | Comma-separated tool list | |
| 18 | +| `--tool NAME` | No | none | Add one tool (repeatable) | |
| 19 | +| `--manager NAME` | No | `auto` | `auto\|brew\|apt\|dnf\|yum` | |
| 20 | +| `--yes` | No | `false` | Non-interactive package install | |
| 21 | +| `--dry-run` | No | `false` | Print commands only | |
| 22 | +| `--update-cache` | No | `false` | Refresh package metadata before install | |
| 23 | + |
| 24 | +## Scenarios |
| 25 | +- Happy path: missing tools are installed, existing tools are skipped. |
| 26 | +- Common operational path: bootstrap a fresh developer workstation. |
| 27 | +- Failure path: unsupported manager/tool mapping or package install failure. |
| 28 | +- Recovery/rollback path: rerun with explicit manager/tool list and fixed package sources. |
| 29 | + |
| 30 | +## Usage |
| 31 | +```bash |
| 32 | +setup/local/install-cli-tools.sh --update-cache --yes |
| 33 | +setup/local/install-cli-tools.sh --manager brew --tools git,jq,shellcheck,shfmt |
| 34 | +setup/local/install-cli-tools.sh --tool kubectl --tool terraform --dry-run |
| 35 | +``` |
| 36 | + |
| 37 | +## Behavior |
| 38 | +- Main execution flow: detect manager, optionally update cache, install requested/missing tools. |
| 39 | +- Idempotency notes: idempotent for already-installed tools. |
| 40 | +- Side effects: system package installation and updates. |
| 41 | + |
| 42 | +## Output |
| 43 | +- Standard output format: timestamped installation logs on stderr. |
| 44 | +- Exit codes: |
| 45 | + - `0` all requested tools available/installed |
| 46 | + - `1` one or more tools failed/unsupported |
| 47 | + - `2` invalid arguments |
| 48 | + |
| 49 | +## Failure Modes |
| 50 | +- Common errors and likely causes: |
| 51 | + - no supported package manager found |
| 52 | + - package unavailable in configured repositories |
| 53 | + - insufficient privileges for system install |
| 54 | +- Recovery and rollback steps: |
| 55 | + - verify repository configuration and credentials |
| 56 | + - rerun with explicit `--manager` |
| 57 | + - install failed tools manually and rerun verification |
| 58 | + |
| 59 | +## Security Notes |
| 60 | +- Secret handling: no secret input expected. |
| 61 | +- Least-privilege requirements: use elevated privileges only for package operations. |
| 62 | +- Audit/logging expectations: installation logs should be retained during bootstrap. |
| 63 | + |
| 64 | +## Testing |
| 65 | +- Unit tests: |
| 66 | + - manager/tool mapping logic |
| 67 | + - argument parsing |
| 68 | +- Integration tests: |
| 69 | + - dry-run/install behavior on supported OS images |
| 70 | +- Manual verification: |
| 71 | + - run then confirm each tool in `PATH` |
0 commit comments