You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The examples reference v. 0.90.2 and nushell is now at (0.101.1) - I think there have been a lot of changes to the plugin interface, in particular the streaming interface.
For SimplePluginCommand, it is enough to rename fn usage() to fn description() - then it compiles and seems to work ok. For PluginCommand() it is more complicated.
In section "under the hood" there is this example:
Putting that together, it looks like this:
$ ./target/release/nu_plugin_len --stdio
json{"Hello":{"protocol":"nu-plugin","version":"0.90.2","features":[]}}
{"Hello":{"protocol":"nu-plugin","version":"0.90.2","features":[]}}
{"Call":[0,"Signature"]}
{"CallResponse":[0, {"Signature":[{"sig":{"name":"len","usage":"calculates the length of its input","extra_usage":"","search_terms":[],"required_positional":[],"optional_positional":[],"rest_positional":null,"vectorizes_over_list":false,"named":[{"long":"help","short":"h","arg":null,"required":false,"desc":"Display the help message for this command","var_id":null,"default_value":null}],"input_type":"String","output_type":"Int","input_output_types":[],"allow_variants_without_examples":false,"is_filter":false,"creates_scope":false,"allows_unknown_args":false,"category":"Default"},"examples":[]}]}]}
I does work - with the SimplePluginCommand implementation - but I think it should be re-written using piped input. Input and output in this version are interleaved and it is not possible - at least in my terminal - to interactively input the example; Plugin waits for enter and input terminates after enter.
It doesn't work as listed any more and in any case, it would be good to have an explanation of where 100953 comes from.
I guess 100953 and 100957 are indexes into the input buffer - beginning and end of "hello". But why are the indexes so large?
Are they stable over different shell sessions?
The text was updated successfully, but these errors were encountered:
It doesn't work as listed any more and in any case, it would be good to have an explanation of where 100953 comes from.
I guess 100953 and 100957 are indexes into the input buffer - beginning and end of "hello". But why are the indexes so large?
These are span offsets and the indexes grow as files and repl is read into memory. You can see an example of these with view files
Are they stable over different shell sessions?
I wouldn't rely on it being stable over different sessions. If you change config files or files you source, the offsets will be different. Or if you run a command initially after you start the repl and then 20 commands later, the offsets will be different.
This page is not up to date - I read it recently for the first time and tried to follow the examples:
https://www.nushell.sh/contributor-book/plugins.html#creating-a-plugin-in-rust
The examples reference v. 0.90.2 and nushell is now at (0.101.1) - I think there have been a lot of changes to the plugin interface, in particular the streaming interface.
For SimplePluginCommand, it is enough to rename fn usage() to fn description() - then it compiles and seems to work ok. For PluginCommand() it is more complicated.
In section "under the hood" there is this example:
I does work - with the SimplePluginCommand implementation - but I think it should be re-written using piped input. Input and output in this version are interleaved and it is not possible - at least in my terminal - to interactively input the example; Plugin waits for enter and input terminates after enter.
There is also this example in the section:
It doesn't work as listed any more and in any case, it would be good to have an explanation of where 100953 comes from.
I guess 100953 and 100957 are indexes into the input buffer - beginning and end of "hello". But why are the indexes so large?
Are they stable over different shell sessions?
The text was updated successfully, but these errors were encountered: