Skip to content

Add argument completer for Build.ps1 -Tasks to enable tab-expansion of task names#569

Open
raandree wants to merge 6 commits into
gaelcolas:mainfrom
raandree:feature/#568
Open

Add argument completer for Build.ps1 -Tasks to enable tab-expansion of task names#569
raandree wants to merge 6 commits into
gaelcolas:mainfrom
raandree:feature/#568

Conversation

@raandree
Copy link
Copy Markdown
Contributor

@raandree raandree commented Apr 22, 2026

Pull Request (PR) description

Adds an [ArgumentCompleter()] attribute to the -Tasks parameter in the scaffolded Build.ps1 template so that pressing Tab after -Tasks cycles through the available task names and workflow aliases. [closes #568]

The completer is self-contained and has no dependency on Sampler or Invoke-Build being loaded, so it works in a fresh clone before Resolve-Dependency has ever run. Task names are discovered by textual scanning (regex matching task <Name> declarations) rather than dot-sourcing, keeping completion fast and side-effect free.

Completion candidates include:

  • The built-in Invoke-Build ? help token.
  • Tasks defined locally under ./.build/**/*.ps1.
  • Tasks imported from Sampler and related modules under ./output/RequiredModules/**/*.build.ps1.
  • Workflow aliases declared under BuildWorkflow: in build.yaml.

Results are deduplicated case-insensitively, sorted alphabetically, and filtered by the partially typed word. Missing or unreadable source locations are silently ignored.

Added

  • Tab-completion for the -Tasks parameter of the scaffolded Build.ps1.
    Candidates include the Invoke-Build ? help token, tasks defined under
    ./.build/**/*.ps1, tasks imported from modules under
    ./output/RequiredModules/**/*.build.ps1, and workflow aliases declared
    under BuildWorkflow: in build.yaml. The completer is self-contained and
    works in a fresh clone before Resolve-Dependency has ever run. [closes Add argument completer for Build.ps1 -Tasks to enable tab-expansion of task names #568]

Task list

  • The PR represents a single logical change. i.e. Cosmetic updates should go in different PRs.
  • Added an entry under the Unreleased section of in the CHANGELOG.md as per format.
  • Local clean build passes without issue or fail tests (build.ps1 -ResolveDependency).
  • Documentation added/updated in README.md.
  • Comment-based help added/updated.
  • Localization strings added/updated in all localization files as appropriate.
  • Unit tests added/updated. See DSC Community Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Community Testing Guidelines.
  • New/changed code adheres to DSC Community Style Guidelines.

This change is Reviewable

@gaelcolas
Copy link
Copy Markdown
Owner

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@johlju
Copy link
Copy Markdown
Collaborator

johlju commented Apr 23, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@raandree
Copy link
Copy Markdown
Contributor Author

raandree commented May 2, 2026

Can we trigger the Azure pipeline, please?

@johlju
Copy link
Copy Markdown
Collaborator

johlju commented May 2, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Comment thread Sampler/Templates/Build/build.ps1 Outdated
Comment thread tests/Unit/Templates/Build.ps1.Tests.ps1
Comment thread GitVersion.yml
Comment thread Sampler/Templates/Build/build.ps1 Outdated
Comment thread tests/Unit/Templates/Build.ps1.Tests.ps1 Outdated
Comment thread tests/Unit/Templates/Build.ps1.Tests.ps1 Outdated
raandree added 2 commits May 9, 2026 22:06
The task-discovery regex used by the Build.ps1 -Tasks tab-completer
captured identifiers that merely appear after the literal text "task"
inside a comment block. For example, the comment line

    task parameter $CodeCoverageThreshold is passed on the

inside Sampler''s own Invoke-Pester.pester.build.ps1 produced "paramete"
as a stray completion candidate (the engine backtracked the greedy name
capture by one character so the lookahead could match a word follower).

Anchor the captured name to a real word boundary by requiring either
optional whitespace then a syntax char, mandatory whitespace then a
word char (next Invoke-Build Job string), or end-of-line.

Add a unit-test fixture with a comment block that contains a
"task comment ..." line and assert that "comment" is NOT emitted as a
completion candidate.
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.

Add argument completer for Build.ps1 -Tasks to enable tab-expansion of task names

3 participants