feat(flags): WI-2 --only selective install + order preservation (#468) - #498
Merged
Merged
Conversation
) Implements the --only/-Only flag for selective tool installation on both Linux/macOS and Windows. Closes the gap that unblocks #466 (git-delta) and #467 (lazygit) as opt-in tools reachable via --only. Changes: - scripts/linux/setup.sh: ARG_ONLY_SET sentinel + order-preserving build_final_toolset: iterates DEFAULT_TOOLS to filter requested tools (default order maintained), then appends opt-in tools alphabetically. Empty --only= now correctly exits 1. - scripts/windows/setup.ps1: \System.Management.Automation.PSBoundParametersDictionary.ContainsKey('Only') guard so empty -Only '' correctly exits 1; same order-preservation logic as Linux (DefaultTools filter + alphabetical opt-in append). - setup.ps1 (root): adds \/\ params + forwarding so root entry point correctly propagates -Only/-Skip to platform script. - tests/test_setup_flags.sh: 12 WI-2 bash tests (order-preservation, opt-in reachability, blank CSV validation, copilot-cli alias, backward compat gate, root forwarding). - tests/test_setup_flags_pwsh.ps1: 13 WI-2 PS tests (same coverage). Order-preservation invariant: --only=copilot-cli,nvm installs nvm BEFORE copilot-cli because DEFAULT_TOOLS defines that order. Opt-in tools (not in DEFAULT_TOOLS) append after default-ordered tools, alphabetically. Bash 3.2 safe: no mapfile/local -n/declare -n. PSScriptAnalyzer clean: approved verbs, singular nouns, used params. ASCII-only. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Root setup.ps1 used 'if (\)' to decide whether to forward the param. Empty string is falsy in PS, so '-Only ''' was never forwarded to the child script -- the child saw no -Only and ran the full default install (exit 0) instead of erroring as expected. Fix: use \System.Management.Automation.PSBoundParametersDictionary.ContainsKey for both -Only and -Skip so an explicitly-passed empty string is forwarded and the child's exit-1 guard fires correctly. Consistent with how scripts/linux/setup.sh forwards '\$@' verbatim and with the child script's own ContainsKey guard. Add T_root_only_empty to tests/test_setup_flags_pwsh.ps1 to close the test gap: asserts root setup.ps1 -Only '' exits non-zero. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WI-2:
--onlySelective Install + Order Preservation (#468)Part of the flags-first customizable install plan — see #468.
What's in scope
--only=<csv>/-Only "<csv>"— installs ONLY the listed tools and exits.DEFAULT_TOOLS/$DefaultToolsorder, NOT input order.--only=copilot-cli,nvmstill installsnvmbeforecopilot-cli(npm must be on PATH first).tools/or registry but NOT inDEFAULT_TOOLS) arereachable via
--only. They append after the default-ordered tools, alphabetically.This gives Install delta (git-delta) as an opt-in tool #466 (git-delta) and Install lazygit as an opt-in tool #467 (lazygit) a home.
--only=copilot-cliworks on both platforms: thecopilot-cli->Install-CopilotClialias was already in the Windows
$ToolRegistry(WI-1, Q3 decision); Linux uses thecopilot-cli.shscript by filename.setup.ps1now forwards-Only/-Skip(params were intentionally omitted inWI-1 as YAGNI — now implemented).
--only=/--only=,foo/--only=foo,,barallexit 1 with a clear error.
--list.What is NOT in scope (WI-3)
--skipflag (code already exists from WI-1 skeleton but is WI-3 scope)--only/--skipmutual-exclusion enforcement (WI-3)Unblocks
--only=delta--only=lazygitTest results — TDD red → green
Bash (
tests/test_setup_flags.sh)WI-2 tests added: 12
T_only_order_preserved,T_only_optin_orderAfter implementation: 12/12 GREEN (10 WI-1 + 12 WI-2 = all pass)
PowerShell (
tests/test_setup_flags_pwsh.ps1)WI-2 tests added: 13
T_only_order_preserved,T_only_optin_order,T_root_onlyAfter implementation: 23/23 GREEN (10 WI-1 + 13 WI-2 = all pass)
Backward-compat gate:
T_backward_compat_gate(bash + PS) confirms no-arg run stillproduces full
DEFAULT_TOOLSlist in order — no regression.Pre-existing failures (unchanged from develop): 8 failures in
test_windows_setup.ps1(copilot-live + O-1..O-7). No new regressions introduced.
Implementation notes
build_final_toolset()iteratesDEFAULT_TOOLSand includeseach tool if it was requested. Opt-in tools (not in
DEFAULT_TOOLS) are collected andappended sorted alphabetically. Bash 3.2 safe: no
mapfile,local -n,declare -n.foreach ($tool in $DefaultTools)filter +Sort-Objectforopt-in tools. Uses
$PSBoundParameters.ContainsKey('Only')to correctly distinguish"not passed" from "passed as empty string".
setup.ps1:$Only/$Skipadded to param block; forwarded in$_fwdParamsat script scope (PSAnalyzer sees them as used).Files touched
scripts/linux/setup.shARG_ONLY_SETsentinel + order-preservingbuild_final_toolsetscripts/windows/setup.ps1$PSBoundParametersguard + order-preserving$FinalToolsbuildsetup.ps1(root)$Only/$Skipparams + forward to platform scripttests/test_setup_flags.shtests/test_setup_flags_pwsh.ps1Closes partial milestone of #468. Base:
develop.