mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-27 02:39:38 +02:00
feat(config,cli): omnigraph use active-context graph selection
Add omnigraph use <graph>: validate the graph resolves in the merged config (loud
fail otherwise), then write ~/.omnigraph/state/active.yaml ({graph}). The layered
loader reads it as the State layer between Global and Project, so a bare command
targets the active graph — Project still overrides State, State overrides Global.
The State layer is synthetic (sets defaults.graph only) and raises no version/legacy
warnings.
This commit is contained in:
parent
2bf3e45d08
commit
67a07cfec3
3 changed files with 176 additions and 7 deletions
|
|
@ -26,8 +26,8 @@ use omnigraph_compiler::{
|
|||
json_params_to_param_map, lint_query_file,
|
||||
};
|
||||
use omnigraph_config::{
|
||||
AliasCommand, GraphLocator, OmnigraphConfig, Provenance, ReadOutputFormat,
|
||||
graph_resource_id_for_selection, load_layered_config,
|
||||
ActiveContext, AliasCommand, GraphLocator, OmnigraphConfig, Provenance, ReadOutputFormat,
|
||||
graph_resource_id_for_selection, load_layered_config, write_active_context,
|
||||
};
|
||||
use omnigraph_policy::{
|
||||
PolicyAction, PolicyDecision, PolicyEngine, PolicyRequest, PolicyTestConfig,
|
||||
|
|
@ -318,6 +318,14 @@ enum Command {
|
|||
#[command(subcommand)]
|
||||
command: ConfigCommand,
|
||||
},
|
||||
/// Set the active graph (writes `~/.omnigraph/state/active.yaml`).
|
||||
Use {
|
||||
/// Graph to make active (must resolve in the merged config).
|
||||
graph: String,
|
||||
/// Project config file (defaults to ./omnigraph.yaml).
|
||||
#[arg(long)]
|
||||
config: Option<PathBuf>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Operations on the graph registry of a multi-graph server (MR-668).
|
||||
|
|
@ -3200,6 +3208,17 @@ async fn main() -> Result<()> {
|
|||
)?;
|
||||
}
|
||||
},
|
||||
Command::Use { graph, config } => {
|
||||
// Validate the graph resolves against the current merged config before
|
||||
// making it the active default (loud fail on an unknown graph).
|
||||
let resolved = load_cli_config(config.as_ref())?;
|
||||
resolved.resolve_graph(None, Some(&graph))?;
|
||||
write_active_context(&ActiveContext {
|
||||
graph: graph.clone(),
|
||||
server: None,
|
||||
})?;
|
||||
println!("active graph set to '{graph}'");
|
||||
}
|
||||
Command::Optimize {
|
||||
uri,
|
||||
target,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue