sqlite_graphrag/commands/merge_entities/
args.rs1use crate::output::OutputFormat;
4
5#[derive(clap::Args)]
6#[command(after_long_help = "EXAMPLES:\n \
7 # Merge two source entities into a target\n \
8 sqlite-graphrag merge-entities --names auth,authentication --into auth-service\n\n \
9 # Merge three sources into one target across a namespace\n \
10 sqlite-graphrag merge-entities --names svc-a,svc-b,old-svc --into canonical-service --namespace my-project\n\n \
11 # Merge by ID (unambiguous when homonyms exist across namespaces)\n \
12 sqlite-graphrag merge-entities --ids 12,17 --into-id 3\n\n\
13NOTE:\n \
14 --names is a comma-separated list of source entity names.\n \
15 --into is the target entity name and must already exist.\n \
16 --ids / --into-id select entities by ID; IDs are globally unique so they\n \
17 disambiguate homonyms. They conflict with --names / --into respectively\n \
18 and must belong to the resolved namespace.\n \
19 Source entities are deleted after the merge; the target is preserved.\n \
20 Duplicate relationships (same endpoints + relation) are removed automatically.\n \
21 Run `sqlite-graphrag cleanup-orphans` afterwards if sources had no other links.")]
22pub struct MergeEntitiesArgs {
24 #[arg(
26 long,
27 value_delimiter = ',',
28 value_name = "NAMES",
29 required_unless_present = "ids",
30 conflicts_with = "ids"
31 )]
32 pub names: Vec<String>,
33 #[arg(long, value_delimiter = ',', value_name = "IDS")]
37 pub ids: Vec<i64>,
38 #[arg(
40 long,
41 value_name = "TARGET",
42 required_unless_present = "into_id",
43 conflicts_with = "into_id"
44 )]
45 pub into: Option<String>,
46 #[arg(long, value_name = "TARGET_ID")]
48 pub into_id: Option<i64>,
49 #[arg(long)]
51 pub namespace: Option<String>,
52 #[arg(long, value_enum, default_value = "json")]
54 pub format: OutputFormat,
55 #[arg(long, hide = true, help = "No-op; JSON is always emitted on stdout")]
57 pub json: bool,
58 #[arg(long)]
60 pub db: Option<String>,
61 #[arg(long, default_value_t = false, hide = false)]
66 pub cross_namespace: bool,
67}