Inconsistent deployment target handling across CLI commands
- Vorherrschende Sprache
- TypeScript
- Sterne
- 283
- Forks
- 95
- Ø Merge
- 1 T. 2 Std.
- Gemergte PRs (30 T.)
- 183
Beschreibung
## Summary
Different CLI commands resolve the `--target` flag with different fallback strategies, making the CLI unintuitive and unpredictable for users managing multiple deployment targets.
## Current Behavior
| Command | Default when `--target` omitted | Multiple targets behavior | Error format when target not found |
|---------|-------------------------------|--------------------------|-----------------------------------|
| `deploy` | Hardcoded `'default'` | No error, silently uses `'default'` | Simple "not found" |
| `invoke` | Hardcoded `'default'` | Uses first deployed target | Shows available target list |
| `status` | First available target | Uses first available target | Shows available target list |
| `import` | `'default'` fallback | Errors, requires `--target` flag | Formatted multi-line list |
### Specific code locations
**Defaults to hardcoded `'default'` string:**
- `src/cli/commands/deploy/command.tsx:156` — `target: cliOptions.target ?? 'default'`
- `src/cli/commands/invoke/command.tsx:155` — `targetName: cliOptions.target ?? 'default'`
- `src/cli/commands/import/actions.ts:484` — `const targetName = target?.name ?? 'default'`
**Defaults to first available (different strategy):**
- `src/cli/commands/status/action.ts:225` — `options.targetName ?? targetNames[0]`
- `src/cli/commands/invoke/action.ts:45` — `options.targetName ?? targetNames[0]!`
- `src/cli/operations/resolve-agent.ts:70` — `targetNames[0]!`
### TUI vs CLI divergence
- **Deploy TUI** (`src/cli/tui/hooks/useAwsTargetConfig.ts`) allows multi-target selection; CLI only accepts one
- **Status TUI** (`src/cli/tui/screens/status/useStatusFlow.ts`) allows cycling through targets; CLI shows only one
- **Import** has no TUI mode at all
## Expected Behavior
All commands should use a single, consistent target resolution strategy:
1. If `--target` specified → validate it exists and use it
2. If exactly one target exists → use it automatically
3. If multiple targets exist and no `--target` specified → error with a list of available targets
4. Error messages should use the same format across all commands
## Proposed Solution
Create a shared `resolveTarget()` utility that all commands call, replacing the per-command ad-hoc logic. This would be a single source of truth for target resolution with consistent error handling.
## Impact
Users with multiple deployment targets (e.g., staging + prod) get different behavior depending on which command they run, which is confusing and can lead to accidentally operating on the wrong target.
Beitragsleitfaden
Rechercherichtung
Beginne mit dem Vergleich der Zielbehandlung in den aufgeführten Dateien deploy, invoke, status, import und resolve-agent und überprüfe anschließend die TUI-Zielabläufe auf bereits vorhandenes Auswahlverhalten. Zentralisiere die Auflösung, sodass explizite Ziele validiert, ein Ziel automatisch ausgewählt und bei mehreren Zielen derselbe Fehler für verfügbare Ziele ausgegeben wird; überprüfe, dass jeder betroffene Befehl diesen Regeln folgt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- cli
- Issue-Typ
- Refactoring
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 52/100