Skip to content

feat: Implement azdo boards work-item list command #136

@tmeckel

Description

@tmeckel

This issue tracks the implementation of the azdo boards work-item list command.

Command Description

List work items belonging to a project within an Azure DevOps organization. Work items are the fundamental units used to plan and track work in Azure Boards (tasks, bugs, user stories, etc.), and the REST API supports retrieving up to 200 items per call (Work Items - List (REST 7.1)). This command provides an ergonomic way to view the project backlog and quickly filter the results by workflow status, classification/severity, assignee, and other backlog attributes without having to author WIQL manually.

Important REST constraints:

  • The “Work Items - List” endpoint fetches work items by ID (max 200 IDs). It does not list a project backlog by itself.
  • To list work items by criteria, the command should run a WIQL query to obtain IDs, then fetch work items in batches.

Command Signature

azdo boards work-item list [ORGANIZATION/]PROJECT
  • Aliases: ls, l
  • Positional parsing must follow the standard project-scoped [ORGANIZATION/]PROJECT splitter. When the organization segment is omitted, resolve it via the configured default. Return a flag error when no organization is provided or configured.

Flags

  • --status, -s: Repeatable flag that accepts the state categories open, closed, resolved, all. Convert the shorthand into WIQL filters using System.StateCategory (open → Proposed/InProgress, closed → Completed/Removed, resolved → Resolved). Default is open.
  • --type, -t: Repeatable flag for one or more work item types (e.g., User Story, Task). Build a WIQL predicate on System.WorkItemType. When omitted, do not filter by type.
  • --assigned-to, -a: Repeatable flag that accepts the same values supported by pull request reviewer resolution (email, org/team, descriptor). Also accept the special token @me to scope to the authenticated user (see Identity-based queries). Resolve identities using the same helpers as internal/cmd/pr/create (identity client lookups) and map @me via extensions.Client.GetSelfID.
  • --classification, -c: Repeatable flag that filters on the severity classification Microsoft.VSTS.Common.Severity. Accept the canonical values documented for bug severity (1 - Critical, 2 - High, 3 - Medium, 4 - Low) and emit a flag error for unknown values (Severity guidance).
  • --priority, -p: Repeatable flag that filters on Microsoft.VSTS.Common.Priority. Accept integer values 1–4 as defined in Azure Boards planning guidance (Priority field reference).
  • --area: Repeatable flag that filters work items assigned to matching area paths. Accept either a fully-qualified area path or the Under: prefix to include an entire subtree (e.g., Under:Web/Payments). Map to System.AreaPath/Under operators per Classification field reference.
  • --iteration: Repeatable flag that filters by iteration (sprint) path. Accept the same syntax as --area, including Under: semantics. Map to System.IterationPath/Under operators per the same classification guidance.
  • --limit, -L: Maximum number of results to return (>=1).
    • Apply $top to WIQL.
    • Fetch work items via GetWorkItemsBatch in chunks of 200 IDs (hard REST limit).
    • Default 50.
  • JSON output flags: call util.AddJSONFlags(cmd, &opts.exporter, []string{...}) so callers can select top-level fields.
    • JSON output should emit the SDK work item model (id, rev, fields, relations, url, _links) and only use an augmented struct if derived/related fields are added.

Implementation Notes (filled checklist)

  • Implement command: internal/cmd/boards/workitem/list/list.go (type opts struct, NewCmd(ctx), run(ctx, opts)).
  • Wire command: internal/cmd/boards/workitem/workitem.go must AddCommand(list.NewCmd(ctx)) and be reachable from azdo boards.
  • Parse project scope: util.ParseProjectScope(ctx, scopeArg); wrap parse errors with util.FlagErrorWrap.
  • Clients:
    • Work Item Tracking: ctx.ClientFactory().WorkItemTracking(ctx.Context(), scope.Organization) using QueryByWiql and GetWorkItemsBatch.
    • Identity / Extensions clients only if required by flags (--assigned-to, @me).
  • Progress: ios.StartProgressIndicator(); defer ios.StopProgressIndicator() and stop before printing.
  • Query algorithm:
    • Build WIQL query from flags.
    • QueryByWiql to get work item references (IDs).
    • Batch-fetch details via GetWorkItemsBatch (chunk size 200).
  • Output:
    • Table: ctx.Printer("table") with stable columns (e.g., ID, TYPE, STATE, TITLE, ASSIGNED TO, AREA, ITERATION).
    • JSON: emit SDK work item model; register selected top-level fields with util.AddJSONFlags.
  • Tests:
    • Add internal/cmd/boards/workitem/list/list_test.go.
    • Hermetic mocks: WorkItemTracking + any identity/extensions clients used.
    • Table-driven cases for each filter + @me resolution + chunking at 200.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions