Add a command to Graphene CLI for listing protonode identifiers (#3399)
* Add proto node name printing * Add subcommand for printing proto node identifiers * Address review comments * Cargo fmt
This commit is contained in:
parent
06484ef4e0
commit
f61aebb777
|
|
@ -7,7 +7,7 @@ use graph_craft::proto::ProtoNetwork;
|
|||
use graph_craft::util::load_network;
|
||||
use graph_craft::wasm_application_io::EditorPreferences;
|
||||
use graphene_std::application_io::{ApplicationIo, NodeGraphUpdateMessage, NodeGraphUpdateSender, RenderConfig};
|
||||
use graphene_std::text_nodes::FontCache;
|
||||
use graphene_std::text::FontCache;
|
||||
use graphene_std::wasm_application_io::{WasmApplicationIo, WasmEditorApi};
|
||||
use interpreted_executor::dynamic_executor::DynamicExecutor;
|
||||
use interpreted_executor::util::wrap_network_in_scope;
|
||||
|
|
@ -56,6 +56,7 @@ enum Command {
|
|||
#[clap(long, short = 'l')]
|
||||
run_loop: bool,
|
||||
},
|
||||
ListNodeIdentifiers,
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
|
|
@ -76,12 +77,20 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||
let document_path = match app.command {
|
||||
Command::Compile { ref document, .. } => document,
|
||||
Command::Run { ref document, .. } => document,
|
||||
Command::ListNodeIdentifiers => {
|
||||
let mut ids: Vec<_> = graphene_std::registry::NODE_METADATA.lock().unwrap().keys().cloned().collect();
|
||||
ids.sort_by_key(|x| x.name.clone());
|
||||
for id in ids {
|
||||
println!("{}", id.name)
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
let document_string = std::fs::read_to_string(document_path).expect("Failed to read document");
|
||||
|
||||
log::info!("creating gpu context",);
|
||||
let mut application_io = block_on(WasmApplicationIo::new());
|
||||
let mut application_io = block_on(WasmApplicationIo::new_offscreen());
|
||||
|
||||
if let Command::Run { image: Some(ref image_path), .. } = app.command {
|
||||
application_io.resources.insert("null".to_string(), Arc::from(std::fs::read(image_path).expect("Failed to read image")));
|
||||
|
|
@ -123,6 +132,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||
tokio::time::sleep(std::time::Duration::from_millis(16)).await;
|
||||
}
|
||||
}
|
||||
_ => unreachable!("All other commands should be handled before this match statement is run"),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
@ -168,7 +178,8 @@ fn fix_nodes(network: &mut NodeNetwork) {
|
|||
// https://github.com/GraphiteEditor/Graphite/blob/d68f91ccca69e90e6d2df78d544d36cd1aaf348e/editor/src/messages/portfolio/portfolio_message_handler.rs#L535
|
||||
// Since the CLI doesn't have the document node definitions, a less robust method of just patching the inputs is used.
|
||||
DocumentNodeImplementation::ProtoNode(proto_node_identifier)
|
||||
if (proto_node_identifier.name.starts_with("core_types::ConstructLayerNode") || proto_node_identifier.name.starts_with("core_types::AddArtboardNode")) && node.inputs.len() < 3 =>
|
||||
if (proto_node_identifier.name.starts_with("graphene_core::ConstructLayerNode") || proto_node_identifier.name.starts_with("graphene_core::AddArtboardNode"))
|
||||
&& node.inputs.len() < 3 =>
|
||||
{
|
||||
node.inputs.push(NodeInput::Reflection(DocumentNodeMetadata::DocumentNodePath));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue