feat(config): Add fetchResourceEvents config flag with --no-events CLI override
Adds a new boolean field to SyncConfig that controls whether resource event fetching is performed during sync: - SyncConfig.fetch_resource_events: defaults to true via serde default_true helper, serialized as "fetchResourceEvents" in JSON - SyncArgs.no_events: --no-events CLI flag that overrides the config value to false when present - SyncOptions.no_events: propagates the flag through the sync pipeline - handle_sync_cmd: mutates loaded config when --no-events is set, ensuring the flag takes effect regardless of config file contents This follows the existing pattern established by --no-embed and --no-docs flags, where CLI flags override config file defaults. The config is loaded as mutable specifically to support this override. Also adds "events" to the count command's entity type value_parser, enabling `lore count events` (implementation in a separate commit). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ pub struct SyncOptions {
|
|||||||
pub force: bool,
|
pub force: bool,
|
||||||
pub no_embed: bool,
|
pub no_embed: bool,
|
||||||
pub no_docs: bool,
|
pub no_docs: bool,
|
||||||
|
pub no_events: bool,
|
||||||
pub robot_mode: bool,
|
pub robot_mode: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -478,6 +478,10 @@ pub struct SyncArgs {
|
|||||||
/// Skip document regeneration
|
/// Skip document regeneration
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub no_docs: bool,
|
pub no_docs: bool,
|
||||||
|
|
||||||
|
/// Skip resource event fetching (overrides config)
|
||||||
|
#[arg(long = "no-events")]
|
||||||
|
pub no_events: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Arguments for `lore embed`
|
/// Arguments for `lore embed`
|
||||||
@@ -501,8 +505,8 @@ pub struct EmbedArgs {
|
|||||||
/// Arguments for `lore count <ENTITY>`
|
/// Arguments for `lore count <ENTITY>`
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
pub struct CountArgs {
|
pub struct CountArgs {
|
||||||
/// Entity type to count (issues, mrs, discussions, notes)
|
/// Entity type to count (issues, mrs, discussions, notes, events)
|
||||||
#[arg(value_parser = ["issues", "mrs", "discussions", "notes"])]
|
#[arg(value_parser = ["issues", "mrs", "discussions", "notes", "events"])]
|
||||||
pub entity: String,
|
pub entity: String,
|
||||||
|
|
||||||
/// Parent type filter: issue or mr (for discussions/notes)
|
/// Parent type filter: issue or mr (for discussions/notes)
|
||||||
|
|||||||
@@ -50,6 +50,13 @@ pub struct SyncConfig {
|
|||||||
|
|
||||||
#[serde(rename = "dependentConcurrency")]
|
#[serde(rename = "dependentConcurrency")]
|
||||||
pub dependent_concurrency: u32,
|
pub dependent_concurrency: u32,
|
||||||
|
|
||||||
|
#[serde(rename = "fetchResourceEvents", default = "default_true")]
|
||||||
|
pub fetch_resource_events: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_true() -> bool {
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for SyncConfig {
|
impl Default for SyncConfig {
|
||||||
@@ -61,6 +68,7 @@ impl Default for SyncConfig {
|
|||||||
cursor_rewind_seconds: 2,
|
cursor_rewind_seconds: 2,
|
||||||
primary_concurrency: 4,
|
primary_concurrency: 4,
|
||||||
dependent_concurrency: 2,
|
dependent_concurrency: 2,
|
||||||
|
fetch_resource_events: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
src/main.rs
20
src/main.rs
@@ -11,14 +11,14 @@ use tracing_subscriber::util::SubscriberInitExt;
|
|||||||
use lore::Config;
|
use lore::Config;
|
||||||
use lore::cli::commands::{
|
use lore::cli::commands::{
|
||||||
InitInputs, InitOptions, InitResult, ListFilters, MrListFilters, SearchCliFilters, open_issue_in_browser,
|
InitInputs, InitOptions, InitResult, ListFilters, MrListFilters, SearchCliFilters, open_issue_in_browser,
|
||||||
open_mr_in_browser, print_count, print_count_json, print_doctor_results, print_generate_docs,
|
open_mr_in_browser, print_count, print_count_json, print_event_count, print_event_count_json, print_doctor_results, print_generate_docs,
|
||||||
print_generate_docs_json, print_ingest_summary, print_ingest_summary_json, print_list_issues,
|
print_generate_docs_json, print_ingest_summary, print_ingest_summary_json, print_list_issues,
|
||||||
print_list_issues_json, print_list_mrs, print_list_mrs_json, print_search_results,
|
print_list_issues_json, print_list_mrs, print_list_mrs_json, print_search_results,
|
||||||
print_search_results_json, print_show_issue, print_show_issue_json, print_show_mr, print_stats,
|
print_search_results_json, print_show_issue, print_show_issue_json, print_show_mr, print_stats,
|
||||||
print_stats_json,
|
print_stats_json,
|
||||||
print_embed, print_embed_json, print_sync, print_sync_json,
|
print_embed, print_embed_json, print_sync, print_sync_json,
|
||||||
print_show_mr_json, print_sync_status, print_sync_status_json, run_auth_test, run_count,
|
print_show_mr_json, print_sync_status, print_sync_status_json, run_auth_test, run_count,
|
||||||
run_doctor, run_embed, run_generate_docs, run_ingest, run_init, run_list_issues, run_list_mrs,
|
run_count_events, run_doctor, run_embed, run_generate_docs, run_ingest, run_init, run_list_issues, run_list_mrs,
|
||||||
run_search, run_show_issue, run_show_mr, run_stats, run_sync, run_sync_status, SyncOptions,
|
run_search, run_show_issue, run_show_mr, run_stats, run_sync, run_sync_status, SyncOptions,
|
||||||
IngestDisplay,
|
IngestDisplay,
|
||||||
};
|
};
|
||||||
@@ -518,6 +518,16 @@ async fn handle_count(
|
|||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let config = Config::load(config_override)?;
|
let config = Config::load(config_override)?;
|
||||||
|
|
||||||
|
if args.entity == "events" {
|
||||||
|
let counts = run_count_events(&config)?;
|
||||||
|
if robot_mode {
|
||||||
|
print_event_count_json(&counts);
|
||||||
|
} else {
|
||||||
|
print_event_count(&counts);
|
||||||
|
}
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let result = run_count(&config, &args.entity, args.for_entity.as_deref())?;
|
let result = run_count(&config, &args.entity, args.for_entity.as_deref())?;
|
||||||
if robot_mode {
|
if robot_mode {
|
||||||
print_count_json(&result);
|
print_count_json(&result);
|
||||||
@@ -1128,12 +1138,16 @@ async fn handle_sync_cmd(
|
|||||||
args: SyncArgs,
|
args: SyncArgs,
|
||||||
robot_mode: bool,
|
robot_mode: bool,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let config = Config::load(config_override)?;
|
let mut config = Config::load(config_override)?;
|
||||||
|
if args.no_events {
|
||||||
|
config.sync.fetch_resource_events = false;
|
||||||
|
}
|
||||||
let options = SyncOptions {
|
let options = SyncOptions {
|
||||||
full: args.full && !args.no_full,
|
full: args.full && !args.no_full,
|
||||||
force: args.force && !args.no_force,
|
force: args.force && !args.no_force,
|
||||||
no_embed: args.no_embed,
|
no_embed: args.no_embed,
|
||||||
no_docs: args.no_docs,
|
no_docs: args.no_docs,
|
||||||
|
no_events: args.no_events,
|
||||||
robot_mode,
|
robot_mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user