@@ -202,51 +202,60 @@ fn validate_schema(graph: &PathBuf) -> anyhow::Result<()> {
202
202
Ok ( ( ) )
203
203
}
204
204
205
- pub async fn handle_graph_command ( command : & GraphCommand ) -> anyhow:: Result < ( ) > {
206
- match command {
207
- GraphCommand :: Create {
208
- number,
209
- outfile,
210
- version,
211
- bitcoin_conf,
212
- } => {
213
- let version_str: & str = version. as_deref ( ) . unwrap_or ( "26.0" ) ;
205
+ fn handle_create_command (
206
+ number : & usize ,
207
+ outfile : & Option < PathBuf > ,
208
+ version : & Option < String > ,
209
+ bitcoin_conf : & Option < PathBuf > ,
210
+ ) -> anyhow:: Result < ( ) > {
211
+ let version_str: & str = version. as_deref ( ) . unwrap_or ( "26.0" ) ;
214
212
215
- // Create empty graph
216
- let graph: DiGraph < ( ) , ( ) > = create_graph ( * number) . context ( "creating graph" ) ?;
213
+ // Create empty graph
214
+ let graph: DiGraph < ( ) , ( ) > = create_graph ( * number) . context ( "creating graph" ) ?;
217
215
218
- // Parse any custom bitcoin conf
219
- let bitcoin_conf: String = handle_bitcoin_conf ( bitcoin_conf. as_deref ( ) ) ;
216
+ // Parse any custom bitcoin conf
217
+ let bitcoin_conf: String = handle_bitcoin_conf ( bitcoin_conf. as_deref ( ) ) ;
220
218
221
- // Dump graph to graphml format
222
- let graphml_buf: Vec < u8 > = convert_to_graphml ( & graph) . context ( "Convert to graphml" ) ?;
219
+ // Dump graph to graphml format
220
+ let graphml_buf: Vec < u8 > = convert_to_graphml ( & graph) . context ( "Convert to graphml" ) ?;
223
221
224
- // Configure graphml output settings
225
- let graphml_config = EmitterConfig {
226
- write_document_declaration : true ,
227
- perform_indent : true ,
228
- indent_string : Cow :: Borrowed ( " " ) ,
229
- line_separator : Cow :: Borrowed ( "\n " ) ,
230
- ..Default :: default ( ) // Keep other defaults
231
- } ;
222
+ // Configure graphml output settings
223
+ let graphml_config = EmitterConfig {
224
+ write_document_declaration : true ,
225
+ perform_indent : true ,
226
+ indent_string : Cow :: Borrowed ( " " ) ,
227
+ line_separator : Cow :: Borrowed ( "\n " ) ,
228
+ ..Default :: default ( ) // Keep other defaults
229
+ } ;
232
230
233
- // Add custom elements to graph
234
- let modified_graphml: xmltree:: Element =
235
- add_custom_attributes ( graphml_buf, version_str, bitcoin_conf. as_str ( ) ) ;
231
+ // Add custom elements to graph
232
+ let modified_graphml: xmltree:: Element =
233
+ add_custom_attributes ( graphml_buf, version_str, bitcoin_conf. as_str ( ) ) ;
236
234
237
- // Write either to outfile or stdout
238
- match outfile {
239
- Some ( path) => {
240
- let file = File :: create ( path) . context ( "Writing final graphml file" ) ?;
241
- modified_graphml. write_with_config ( file, graphml_config) ?;
242
- }
243
- None => {
244
- let stdout = std:: io:: stdout ( ) ;
245
- let handle = stdout. lock ( ) ;
246
- modified_graphml. write_with_config ( handle, graphml_config) ?;
247
- }
248
- }
235
+ // Write either to outfile or stdout
236
+ match outfile {
237
+ Some ( path) => {
238
+ let file = File :: create ( path) . context ( "Writing final graphml file" ) ?;
239
+ modified_graphml. write_with_config ( file, graphml_config) ?;
240
+ }
241
+ None => {
242
+ let stdout = std:: io:: stdout ( ) ;
243
+ let handle = stdout. lock ( ) ;
244
+ modified_graphml. write_with_config ( handle, graphml_config) ?;
249
245
}
246
+ }
247
+ Ok ( ( ) )
248
+ }
249
+
250
+ pub async fn handle_graph_command ( command : & GraphCommand ) -> anyhow:: Result < ( ) > {
251
+ match command {
252
+ GraphCommand :: Create {
253
+ number,
254
+ outfile,
255
+ version,
256
+ bitcoin_conf,
257
+ } => handle_create_command ( number, outfile, version, bitcoin_conf)
258
+ . context ( "Create a graph" ) ?,
250
259
251
260
GraphCommand :: Validate { graph } => {
252
261
let _ = validate_schema ( graph) ;
0 commit comments