cmdUpdateProject implements `flow update project [--priority ]`. Project field edits are minimal — priority is the only post-creation field with a real reason to change. Status and other shape edits go through `flow archive` / `flow edit`.
(args []string)
| 340 | // field with a real reason to change. Status and other shape edits go |
| 341 | // through `flow archive` / `flow edit`. |
| 342 | func cmdUpdateProject(args []string) int { |
| 343 | if len(args) < 1 { |
| 344 | fmt.Fprintln(os.Stderr, "error: update project requires a project ref") |
| 345 | return 2 |
| 346 | } |
| 347 | ref := args[0] |
| 348 | fs := flagSet("update project") |
| 349 | priority := fs.String("priority", "", "new priority: high|medium|low") |
| 350 | if err := fs.Parse(args[1:]); err != nil { |
| 351 | return 2 |
| 352 | } |
| 353 | if *priority == "" { |
| 354 | fmt.Fprintln(os.Stderr, "error: give at least one of --priority") |
| 355 | return 2 |
| 356 | } |
| 357 | if !isValidPriority(*priority) { |
| 358 | fmt.Fprintf(os.Stderr, |
| 359 | "error: --priority must be high|medium|low (got %q)\n", *priority) |
| 360 | return 2 |
| 361 | } |
| 362 | |
| 363 | dbPath, err := flowDBPath() |
| 364 | if err != nil { |
| 365 | fmt.Fprintf(os.Stderr, "error: %v\n", err) |
| 366 | return 1 |
| 367 | } |
| 368 | db, err := flowdb.OpenDB(dbPath) |
| 369 | if err != nil { |
| 370 | fmt.Fprintf(os.Stderr, "error: open db: %v\n", err) |
| 371 | return 1 |
| 372 | } |
| 373 | defer db.Close() |
| 374 | |
| 375 | p, err := ResolveProject(db, ref, true) |
| 376 | if err != nil { |
| 377 | if errors.Is(err, sql.ErrNoRows) { |
| 378 | fmt.Fprintf(os.Stderr, "error: project %q not found\n", ref) |
| 379 | return 1 |
| 380 | } |
| 381 | fmt.Fprintf(os.Stderr, "error: %v\n", err) |
| 382 | return 1 |
| 383 | } |
| 384 | |
| 385 | now := flowdb.NowISO() |
| 386 | if _, err := db.Exec( |
| 387 | `UPDATE projects SET priority=?, updated_at=? WHERE slug=?`, |
| 388 | *priority, now, p.Slug, |
| 389 | ); err != nil { |
| 390 | fmt.Fprintf(os.Stderr, "error: update priority: %v\n", err) |
| 391 | return 1 |
| 392 | } |
| 393 | fmt.Printf("priority → %s\n", *priority) |
| 394 | return 0 |
| 395 | } |
| 396 | |
| 397 | // parseDueDate converts a human-friendly date expression to a time.Time. |
| 398 | // Accepts: YYYY-MM-DD, today, tomorrow, weekday names (next occurrence), |
no test coverage detected