@@ -549,7 +549,7 @@ pub struct Crafting {
549549 pub selected_action : Option < & ' static str > ,
550550 // Input index to item index
551551 pub input_items : HashMap < usize , usize > ,
552- pub output_filename : String ,
552+ pub outputs_filename : Vec < String > ,
553553 pub craft_result : Option < Result < Vec < PathBuf > > > ,
554554 pub commit_result : Option < Result < PathBuf > > ,
555555}
@@ -737,11 +737,20 @@ impl App {
737737
738738 self . crafting . selected_action = selected_action;
739739
740- // NOTE: If we don't show filenames in the left panel, then we shouldn't ask for a
741- // filename either.
742- if self . crafting . output_filename . is_empty ( ) {
743- self . crafting . output_filename =
744- format ! ( "{:?}_{}" , process, self . items. len( ) + self . used_items. len( ) ) ;
740+ // prepare the outputs names that will be used to store the outputs files
741+ let process_outputs = process. data ( ) . outputs ;
742+ if self . crafting . outputs_filename . is_empty ( ) {
743+ self . crafting . outputs_filename = process_outputs
744+ . iter ( )
745+ . enumerate ( )
746+ . map ( |( i, process_output) | {
747+ format ! (
748+ "{}_{}" ,
749+ process_output,
750+ self . items. len( ) + self . used_items. len( ) + i
751+ )
752+ } )
753+ . collect ( ) ;
745754 }
746755
747756 ui. add_space ( 8.0 ) ;
@@ -771,11 +780,15 @@ impl App {
771780 } ) ;
772781
773782 if button_craft_clicked {
774- if self . crafting . output_filename . is_empty ( ) {
783+ if self . crafting . outputs_filename . is_empty ( ) {
775784 self . crafting . craft_result = Some ( Err ( anyhow ! ( "Please enter a filename." ) ) ) ;
776785 } else {
777- let output =
778- Path :: new ( & self . cfg . pods_path ) . join ( & self . crafting . output_filename ) ;
786+ let outputs_paths = self
787+ . crafting
788+ . outputs_filename
789+ . iter ( )
790+ . map ( |output| Path :: new ( & self . cfg . pods_path ) . join ( output) )
791+ . collect ( ) ;
779792 let input_paths = ( 0 ..inputs. len ( ) )
780793 . map ( |i| {
781794 self . crafting
@@ -798,7 +811,7 @@ impl App {
798811 params : self . params . clone ( ) ,
799812 pods_path : self . cfg . pods_path . clone ( ) ,
800813 recipe,
801- output ,
814+ outputs : outputs_paths ,
802815 input_paths,
803816 } )
804817 . unwrap ( ) ;
@@ -809,7 +822,7 @@ impl App {
809822 }
810823
811824 if button_commit_clicked {
812- if self . crafting . output_filename . is_empty ( ) {
825+ if self . crafting . outputs_filename . is_empty ( ) {
813826 self . crafting . commit_result = Some ( Err ( anyhow ! ( "Please enter a filename." ) ) ) ;
814827 } else if self . crafting . craft_result . is_none ( )
815828 || self . crafting . craft_result . as_ref ( ) . unwrap ( ) . is_err ( )
@@ -837,11 +850,15 @@ impl App {
837850 }
838851
839852 if button_craft_and_commit_clicked {
840- if self . crafting . output_filename . is_empty ( ) {
853+ if self . crafting . outputs_filename . is_empty ( ) {
841854 self . crafting . commit_result = Some ( Err ( anyhow ! ( "Please enter a filename." ) ) ) ;
842855 } else {
843- let output =
844- Path :: new ( & self . cfg . pods_path ) . join ( & self . crafting . output_filename ) ;
856+ let outputs_paths = self
857+ . crafting
858+ . outputs_filename
859+ . iter ( )
860+ . map ( |output| Path :: new ( & self . cfg . pods_path ) . join ( output) )
861+ . collect ( ) ;
845862 let input_paths = ( 0 ..inputs. len ( ) )
846863 . map ( |i| {
847864 self . crafting
@@ -865,7 +882,7 @@ impl App {
865882 cfg : self . cfg . clone ( ) ,
866883 pods_path : self . cfg . pods_path . clone ( ) ,
867884 recipe,
868- output ,
885+ outputs : outputs_paths ,
869886 input_paths,
870887 } )
871888 . unwrap ( ) ;
0 commit comments