Skip to content

Commit 6ebf4b4

Browse files
authored
document uniqueness requirement for app names (#132)
...and provide a friendlier diagnostic when there's a conflict. Fixes #131 Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent c66d95b commit 6ebf4b4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/command.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ pub enum Command {
7979

8080
#[derive(clap::Args, Debug)]
8181
pub struct Componentize {
82-
/// The name of a Python module containing the app to wrap
82+
/// The name of a Python module containing the app to wrap.
83+
///
84+
/// Note that this should not match (any of) the world name(s) you are targeting since `componentize-py` will
85+
/// generate code using those name(s), and Python doesn't know how to load two top-level modules with the same
86+
/// name.
8387
pub app_name: String,
8488

8589
/// Specify a directory containing the app and/or its dependencies. May be specified more than once.

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,13 @@ pub async fn componentize(
312312
.chain(main_world)
313313
.collect::<IndexSet<_>>();
314314

315+
if worlds
316+
.iter()
317+
.any(|&id| app_name == resolve.worlds[id].name.to_snake_case().escape())
318+
{
319+
bail!("App name `{app_name}` conflicts with world name; please rename your application module.");
320+
}
321+
315322
let summary = Summary::try_new(
316323
&resolve,
317324
&worlds,

0 commit comments

Comments
 (0)