Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust example in plugins chapter of contributers book does not compile in recent versions of Nushell #1066

Open
edhowland opened this issue Sep 19, 2023 · 1 comment

Comments

@edhowland
Copy link
Contributor

The Rust example plugin in https://www.nushell.sh/contributor-book/plugins.html
does not compile with later versions of Nushell. Following the instructions
on the page the Cargo.toml pins the crates to 0.84.0 or whatever your current
version of Nushell is. The sample Cargo.toml on the page pins the crates at
0.80.0. If you replace the Cargo.toml with the example, the project compiles.
The change occurred between 0.80.0 and 0.81.0 in the nu-protocol crate.

The lines in the file: './src/main.rs' from the plugins.md source for the above
web page are:

./src/main.rs:16,17

            .input_type(Type::String)
            .output_type(Type::Int)

The change occurred in this commit:

(I've elided some of the non-relevant details of the commit message)

commit df94052180f45685b2a04ba332da734aa8aa701f
Author: Dan Davison <dandavison7@gmail.com>
Date:   Wed Nov 9 16:55:05 2022 -0500

    Declare input and output types of commands (#6796)
    
...
    * Make it possible to declare input and output types for commands
    
    - Enforce them in tests
    
    * Declare input and output types of commands
    

    * Revert SyntaxShape::Table -> Type::Table change

    Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>

The source lines that changed are in the main nushell repository:

'./crates/nu-protocol/src/signature.rs' (around lines 443 or so)

Changing the lines of the example main.rs to:

            .input_output_type(Type::String, Type::Int)

Allows the project to build.

Additionally, the sample Cargo.toml should be changed to pin both the
'nu-plugin' and 'nu-protocol' crates to at least 0.84.0.

A corresponding PR has also been submitted.

@fdncred
Copy link
Collaborator

fdncred commented Sep 19, 2023

ya, we can have .intput_output_type() or input_output_types() if there are mutliple input output types. I agree that this needs to be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants