-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Summary
The output of Get-GitHubContext -ListAvailable is currently unsorted (appears insertion order). Need deterministic alphabetical ordering by Name while still preserving the current-indicator (">"), selected marker("*" header already present). Also ensure every parameter that accepts -Context (or similar) has its ArgumentCompleter returning contexts sorted by Name.
Requirements
- Get-GitHubContext -ListAvailable must sort contexts by Name (case-insensitive, ordinal) before formatting.
- Preserve the visual indicators (leading '>' on active context row) after sorting.
- Ensure expired / time remaining columns still show correctly.
- All ArgumentCompleter scripts for -Context (and related params like -SourceContext, -TargetContext if present) must return names sorted by Name.
- Centralize / relocate all completer definitions into a completers.ps1 file placed in each main function folder where completers are defined (one file per functional area). If a shared/global context completer exists, create (or update) functions/public/Config/completers.ps1 (or appropriate folder matching Get-GitHubContext location) and move definitions there.
- Avoid breaking existing exports: dot-source completers.ps1 from loader/header or the specific function file so they load automatically.
- Add or update tests to assert sorting for: a) Get-GitHubContext -ListAvailable output order, b) tab completion order for -Context parameters (collect via (Get-Command ).Parameters['Context'].Attributes where applicable or simulate Register-ArgumentCompleter result).
Implementation Notes
- Likely modify the private retrieval function that enumerates contexts before formatting pipeline.
- After selecting active context, perform: $items = $items | Sort-Object -Property Name -CultureInvariant -CaseInsensitive
- Re-apply active marker based on matching name.
- For completers, implement a helper Get-GitHubContextNameList (private) that returns sorted names; completers just call it.
- Ensure no circular dot-sourcing.
Testing
- Create temp contexts (mock) to validate ordering.
- Ensure no regression in existing tests.
Next Steps
- Implement sorting + helper.
- Refactor completers into dedicated files.
- Add/adjust tests.
Acceptance Criteria
All tests green; manual run shows alphabetical order exactly as specified in example.
Example Desired Output Order
github.com/MariusStorhaug
github.com/powershell-for-github
github.com/powershell-for-github/Organization/PSModule
github.com/psmodule-enterprise-app
github.com/psmodule-enterprise-app/Organization/psmodule-test-org3
github.com/psmodule-org-app
Metadata
Metadata
Assignees
Labels
Type
Projects
Status