Skip to content

Add tab completion for array resource names via native argument completers #149

Description

Summary

The module has one ArgumentCompleter in the entire codebase and 30 files using ValidateSet. Meanwhile a large share of the 544 public cmdlets take a -Name (or similar) parameter whose valid values are resource names that already exist on the connected array — file systems, buckets, object store accounts and users, policies, network interfaces, admins, contexts, and so on.

Today a user has to run a Get-Pfb* cmdlet, read the name off the output, and retype or paste it. Tab completion on those parameters would remove that round trip for the most common interactive workflows.

Proposed approach

Register argument completers that query the connected array for candidate names and filter on what the user has typed so far.

Design points worth settling before implementation:

  • Cache with a short TTL. A completer fires on every Tab press. Without a cache, holding Tab issues a burst of REST calls against the array. A small per-resource-type cache keyed on the connection, expiring in seconds rather than minutes, keeps completion responsive without hammering the array.
  • Never throw, never prompt, never block for long. A completer that errors, or that blocks on a slow or unreachable array, degrades the shell itself rather than just failing to help. If there is no connection, or the call fails, or it exceeds a short deadline, the completer should return nothing and stay silent.
  • Use the current connection, not a new one. The completer must resolve the connection the same way a cmdlet does, and must not trigger a login.
  • Quote results containing spaces, so the completed value is usable as typed.
  • Decide which resource types are worth covering first rather than doing all of them at once. The high-traffic interactive ones (file systems, buckets, policies) are the obvious opening set.

ValidateSet remains the right tool where the set of values is fixed and known at authoring time; this issue is only about the values that are only knowable from the array.

Inspiration, and what we are deliberately not doing

The idea is borrowed from PSFramework, which provides a tab-completion system (commonly referred to as TEPP) with registration helpers and built-in result caching.

We are not taking PSFramework as a dependency. Reasons, recorded here so the decision is durable:

  1. PowerShell already provides everything needed natively — the [ArgumentCompleter()] parameter attribute and Register-ArgumentCompleter. What PSFramework adds on top is largely convenience around caching, and the caching policy we want here is specific to a REST-backed array anyway, so we would be writing it regardless.
  2. PSFramework ships a compiled assembly (PSFramework.dll), and on Windows PowerShell 5.1 two versions of the same assembly cannot coexist in one session. Other popular modules depend on PSFramework, so a version mismatch in a user's session would produce a hard load failure.
  3. The module currently declares no RequiredModules. That lets it be installed by copying a folder onto an offline or restricted administrator workstation, which is a property worth keeping for this audience.

Notes on scope

  • Completers are a good candidate for incremental delivery: one resource type, with the caching and failure-handling policy established, then widen.
  • This touches executable module code, so it is not wire-exempt and needs live verification against a real FlashBlade before it merges.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions