| 259 | } |
| 260 | |
| 261 | func wizardSelectSource() (string, error) { |
| 262 | names := sync.RegisteredNames() |
| 263 | if len(names) == 0 { |
| 264 | return "", fmt.Errorf("no sources registered") |
| 265 | } |
| 266 | |
| 267 | options := make([]huh.Option[string], len(names)) |
| 268 | for i, n := range names { |
| 269 | options[i] = huh.NewOption(n, n) |
| 270 | } |
| 271 | |
| 272 | var sourceName string |
| 273 | err := huh.NewSelect[string](). |
| 274 | Title("Where are your tasks?"). |
| 275 | Options(options...). |
| 276 | Value(&sourceName). |
| 277 | Run() |
| 278 | if err != nil { |
| 279 | return "", fmt.Errorf("wizard cancelled: %w", err) |
| 280 | } |
| 281 | return sourceName, nil |
| 282 | } |
| 283 | |
| 284 | func wizardSourceConfig(sourceName string) (sync.SourceConfig, error) { |
| 285 | cfg := sync.SourceConfig{Name: sourceName} |