Rust example in plugins chapter of contributers book does not compile in recent versions of Nushell
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 <[email protected]>
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 <[email protected]>
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.
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.