gyscos / cursive

A Text User Interface library for the Rust programming language
MIT License
4.26k stars 243 forks source link

[Possible bug] Builder example isn't working #747

Open ithinkicancode opened 1 year ago

ithinkicancode commented 1 year ago

Describe the bug The "builder" example in the examples dir isn't working - the program panics.

To Reproduce It seems the builder feature is not released :) but I was trying that out. I set the version to this git repo in toml and added "builder" feature. Then I copied builder.rs and all the associated yaml files and then ran the program. The program panicked with the following error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: RecipeFailed("Dialog", ResolveFailed { var_failure: InvalidConfig { message: "Expected variable as key", config: Object {"LinearLayout": Object {"children": Array [Object {"TextView": String("Fancy prompt")}, String("DummyView"), Object {"Titled": Object {"child": Object {"LabeledField": Object {"label": String("Please write:"), "name": String("edit"), "on_edit": String("$on_edit")}}, "title": String("Edit area")}}, Object {"Button": Object {"callback": String("$randomize"), "label": String("Randomize")}}, Object {"VSpace": Number(2)}, Object {"TextView": Object {"with": Array [Object {"name": String("status")}]}}], "with": Array [Object {"padding": Number(1)}, String("full_width"), Object {"fixed_height": Number(11)}]}} }, config_failure: RecipeFailed("LinearLayout", ResolveFailed { var_failure: InvalidConfig { message: "Expected variable as key", config: Object {"Titled": Object {"child": Object {"LabeledField": Object {"label": String("Please write:"), "name": String("edit"), "on_edit": String("$on_edit")}}, "title": String("Edit area")}} }, config_failure: RecipeNotFound("Titled") }) })', app/src/main.rs:74:32
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I understand if this feature is not ready, as it's not documented anywhere and the builder feature is not published (hence pointing to github in toml). :)

Expected behavior I was hoping the example will work. I like the idea of composing UI in a declarative way.

Screenshots If applicable, add screenshots to help explain your problem.

Environment

Additional context Add any other context about the problem here.

gyscos commented 1 year ago

Hi, and thanks for the report!

The example should have been working (it was working the last time I tried).

It's possible you'd need to update the dependencies (the inventory crate in particular may be susceptible to breaking with new rust versions).

Will investigate when I get a chance.

gyscos commented 1 year ago

I can successfully run cargo run --example builder --features builder from this repo, does that not work for you?

Edit: indeed, running this from a separate crate doesn't seem to work. :(

gyscos commented 1 year ago

I think I found the issue (the builder macro had poor hygiene).

Can you try the latest commit?