noora-single-choice-prompt
Noora Single Choice Prompt
Use this skill when a Swift CLI needs one selection from a known list.
Enum-Backed Pattern
import Noora
enum OutputMode: String, CaseIterable, CustomStringConvertible {
case plain
case rich
case json
var description: String {
switch self {
case .plain: return "Plain text"
case .rich: return "Rich terminal UI"
case .json: return "JSON output"
}
}
}
let selection: OutputMode = Noora().singleChoicePrompt(
title: "Output mode",
question: "Which output style should the CLI prefer?",
description: "Choose the default rendering mode for command output.",
filterMode: .toggleable
)
Filter Modes
.disabled: short lists..toggleable: medium lists where filtering is sometimes useful..enabled: long lists where searching should start immediately.
Guidance
- Use
CaseIterableenums whenever the choices are stable and meaningful in code. - Make
descriptionvalues user-facing, not raw case names. - Leave
autoselectSingleChoiceenabled when a filtered or dynamic list can shrink to one valid option.
Avoid
- Using raw strings throughout the codebase when an enum would model the choice better.
- Dumping verbose paragraphs into each option description.
More from spqw/skills-noora
noora-alerts
Use when building Noora warning, success, error, or info alerts in a Swift CLI. Covers choosing alert type, structuring takeaways, and using `TerminalText` interpolation inside alert copy.
1noora-progress-step
Use when a Swift CLI needs a spinner-style Noora progress step for an async operation. Covers `progressStep`, optional status updates, success and error messages, and sequencing multiple steps.
1noora-text-formatting
Use when composing or formatting Noora `TerminalText` in a Swift CLI. Covers semantic text components such as commands, links, paths, and themed text, plus `Noora().format(...)`.
1noora-collapsible-step
Use when a Swift CLI needs Noora to stream multiple log lines during a task and collapse them on success or failure. Covers `collapsibleStep`, `visibleLines`, and writing readable progress lines.
1noora-text-prompt
Use when gathering free-form text input with Noora in a Swift CLI. Covers `textPrompt`, default values, collapse behavior, and validation rules such as `NonEmptyValidationRule`.
1noora-interactive-tables
Use when building interactive Noora tables in a Swift CLI. Covers selectable tables, paginated tables, lazy paginated loading, updating tables from async sequences, and TTY constraints.
1