---
id: TASK-17.2
title: Align sysbuild run/flash behavior and list output
status: Done
assignee:
  - codex
created_date: '2026-02-27 08:46'
updated_date: '2026-02-27 09:02'
labels: []
dependencies: []
references:
  - docs/zync/README.md
  - docs/zync/lua/zync/api/manager.lua
  - src/core/cmd.rs
parent_task_id: TASK-17
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Update cmd run/flash to match sysbuild behavior in Zync, including list output format and non-sysbuild flag rejection.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 `--list` prints a 1-based list of available sysbuild images in the expected format and exits successfully for sysbuild projects.
- [x] #2 Using `--list` or `--image` on non-sysbuild projects returns a clear error.
- [x] #3 Run/flash uses the resolved sysbuild image directory and preserves existing fallback behavior when the zephyr binary is not found.
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
Plan:
1) Review current `cmd_run`/`cmd_flash` against Zync behavior to ensure non-sysbuild `--list`/`--image` errors and list output format are correct.
2) Implement any remaining alignment (e.g., reject `--image` on non-sysbuild, ensure run/flash uses resolved image dir, keep fallback behavior).
3) Add/adjust tests if needed, then run `just test`.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Aligned run/flash sysbuild behavior: cmd_flash now rejects `--image` for non-sysbuild and accepts image selection for sysbuild; cmd_run rejects `--image` for non-sysbuild; list output already 1-based. Added tests for non-sysbuild image errors. `just test` passes (77 tests).
<!-- SECTION:NOTES:END -->

## Final Summary

<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Aligned sysbuild run/flash behavior with Zync by rejecting `--image` on non-sysbuild projects and routing image selection through sysbuild resolution for flash/run. Added tests for non-sysbuild image errors. `just test` passes.

Tests: `just test`
<!-- SECTION:FINAL_SUMMARY:END -->
