refactor(commands): Add IngestDisplay, resolve_project, and color-aware tables
Ingest: - Introduce IngestDisplay struct with show_progress/show_text booleans to decouple progress bars from text output. Replaces the robot_mode bool parameter with explicit display control, enabling sync to show progress without duplicating summary text (progress_only mode). - Use resolve_project() for --project filtering instead of LIKE queries, providing proper error messages for ambiguous or missing projects. List: - Add colored_cell() helper that checks console::colors_enabled() before applying comfy-table foreground colors, bridging the gap between the console and comfy-table crates for --color flag support. - Use resolve_project() for project filtering (exact ID match). - Improve since filter to return explicit errors instead of silently ignoring invalid values. - Improve format_relative_time for proper singular/plural forms. Search: - Validate --after/--updated-after with explicit error messages. - Handle optional title field (Option<String>) in HydratedRow. Show: - Use resolve_project() for project disambiguation. Sync: - Thread robot_mode via SyncOptions for IngestDisplay selection. - Use IngestDisplay::progress_only() in interactive sync mode. GenerateDocs: - Use resolve_project() for --project filtering. Co-Authored-By: Claude (us.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,8 @@ use tracing::info;
|
||||
use crate::core::db::create_connection;
|
||||
use crate::core::error::Result;
|
||||
use crate::core::paths::get_db_path;
|
||||
use crate::documents::{regenerate_dirty_documents, SourceType};
|
||||
use crate::core::project::resolve_project;
|
||||
use crate::documents::{SourceType, regenerate_dirty_documents};
|
||||
use crate::Config;
|
||||
|
||||
const FULL_MODE_CHUNK_SIZE: i64 = 2000;
|
||||
@@ -81,18 +82,7 @@ fn seed_dirty(
|
||||
|
||||
loop {
|
||||
let inserted = if let Some(project) = project_filter {
|
||||
// Resolve project to ID for filtering
|
||||
let project_id: Option<i64> = conn
|
||||
.query_row(
|
||||
"SELECT id FROM projects WHERE path_with_namespace = ?1 COLLATE NOCASE",
|
||||
[project],
|
||||
|row| row.get(0),
|
||||
)
|
||||
.ok();
|
||||
|
||||
let Some(pid) = project_id else {
|
||||
break;
|
||||
};
|
||||
let project_id = resolve_project(conn, project)?;
|
||||
|
||||
conn.execute(
|
||||
&format!(
|
||||
@@ -101,7 +91,7 @@ fn seed_dirty(
|
||||
FROM {table} WHERE id > ?3 AND project_id = ?4 ORDER BY id LIMIT ?5
|
||||
ON CONFLICT(source_type, source_id) DO NOTHING"
|
||||
),
|
||||
rusqlite::params![type_str, now, last_id, pid, FULL_MODE_CHUNK_SIZE],
|
||||
rusqlite::params![type_str, now, last_id, project_id, FULL_MODE_CHUNK_SIZE],
|
||||
)?
|
||||
} else {
|
||||
conn.execute(
|
||||
|
||||
Reference in New Issue
Block a user