Skip to content

Commit

Permalink
document uniqueness requirement for app names
Browse files Browse the repository at this point in the history
...and provide a friendlier diagnostic when there's a conflict.

Fixes #131

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
  • Loading branch information
dicej committed Dec 9, 2024
1 parent c66d95b commit 99b0bc8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ pub enum Command {

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

/// Specify a directory containing the app and/or its dependencies. May be specified more than once.
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ pub async fn componentize(
.chain(main_world)
.collect::<IndexSet<_>>();

if worlds
.iter()
.any(|&id| app_name == resolve.worlds[id].name.to_snake_case().escape())
{
bail!("App name `{app_name}` conflicts with world name; please rename your application module.");
}

let summary = Summary::try_new(
&resolve,
&worlds,
Expand Down

0 comments on commit 99b0bc8

Please sign in to comment.