Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions node-graph/graphene-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,6 +56,7 @@ enum Command {
#[clap(long, short = 'l')]
run_loop: bool,
},
ListNodeIdentifiers,
}

#[derive(Debug, Args)]
Expand All @@ -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")));
Expand Down Expand Up @@ -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(())
Expand Down Expand Up @@ -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));
}
Expand Down
Loading