mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 01:43:47 +01:00
00b3a07efe
# Description This allows plugins to view the source code of spans. Requested by @ayax79 for implementing `polars ls`. Note that this won't really help you find the location of the span. I'm planning to add another engine call that will return information more similar to what shows up in the miette diagnostics, with filename / line number / some context, but I'll want to refactor some of the existing logic to make that happen, so it was easier to just do this first. I hope this is enough to at least have something somewhat useful show up for `polars ls`. # User-Facing Changes - Example plugin: added `example view span` command # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting - [ ] Add to plugin protocol reference
35 lines
934 B
Rust
35 lines
934 B
Rust
use nu_plugin::{Plugin, PluginCommand};
|
|
|
|
mod commands;
|
|
mod example;
|
|
|
|
pub use commands::*;
|
|
pub use example::ExamplePlugin;
|
|
|
|
impl Plugin for ExamplePlugin {
|
|
fn commands(&self) -> Vec<Box<dyn PluginCommand<Plugin = Self>>> {
|
|
// This is a list of all of the commands you would like Nu to register when your plugin is
|
|
// loaded.
|
|
//
|
|
// If it doesn't appear on this list, it won't be added.
|
|
vec![
|
|
Box::new(Main),
|
|
// Basic demos
|
|
Box::new(One),
|
|
Box::new(Two),
|
|
Box::new(Three),
|
|
// Engine interface demos
|
|
Box::new(Config),
|
|
Box::new(Env),
|
|
Box::new(ViewSpan),
|
|
Box::new(DisableGc),
|
|
// Stream demos
|
|
Box::new(CollectExternal),
|
|
Box::new(ForEach),
|
|
Box::new(Generate),
|
|
Box::new(Seq),
|
|
Box::new(Sum),
|
|
]
|
|
}
|
|
}
|