@@ -511,6 +511,10 @@ pub struct WitOpts {
511511 #[ clap( long, conflicts_with = "importize_world" ) ]
512512 importize : bool ,
513513
514+ /// The name of the world to generate when using `--importize` or `importize-world`.
515+ #[ clap( long = "importize-out-world-name" ) ]
516+ importize_out_world_name : Option < String > ,
517+
514518 /// Generates a WIT world to import a component which corresponds to the
515519 /// selected world.
516520 ///
@@ -549,9 +553,13 @@ impl WitOpts {
549553 let mut decoded = self . decode_input ( ) ?;
550554
551555 if self . importize {
552- self . importize ( & mut decoded, None ) ?;
556+ self . importize ( & mut decoded, None , self . importize_out_world_name . as_ref ( ) ) ?;
553557 } else if self . importize_world . is_some ( ) {
554- self . importize ( & mut decoded, self . importize_world . as_deref ( ) ) ?;
558+ self . importize (
559+ & mut decoded,
560+ self . importize_world . as_deref ( ) ,
561+ self . importize_out_world_name . as_ref ( ) ,
562+ ) ?;
555563 }
556564
557565 // Now that the WIT document has been decoded, it's time to emit it.
@@ -636,7 +644,12 @@ impl WitOpts {
636644 }
637645 }
638646
639- fn importize ( & self , decoded : & mut DecodedWasm , world : Option < & str > ) -> Result < ( ) > {
647+ fn importize (
648+ & self ,
649+ decoded : & mut DecodedWasm ,
650+ world : Option < & str > ,
651+ out_world_name : Option < & String > ,
652+ ) -> Result < ( ) > {
640653 let ( resolve, world_id) = match ( & mut * decoded, world) {
641654 ( DecodedWasm :: Component ( resolve, world) , None ) => ( resolve, * world) ,
642655 ( DecodedWasm :: Component ( ..) , Some ( _) ) => {
@@ -653,7 +666,7 @@ impl WitOpts {
653666 // let pkg = decoded.package();
654667 // let world_id = decoded.resolve().select_world(main, None)?;
655668 resolve
656- . importize ( world_id)
669+ . importize ( world_id, out_world_name . cloned ( ) )
657670 . context ( "failed to move world exports to imports" ) ?;
658671 let resolve = mem:: take ( resolve) ;
659672 * decoded = DecodedWasm :: Component ( resolve, world_id) ;
0 commit comments