wip
This commit is contained in:
parent
b98eee9bd0
commit
c639432091
|
@ -5275,15 +5275,6 @@ pub fn parse_expression(working_set: &mut StateWorkingSet, spans: &[Span]) -> Ex
|
||||||
}
|
}
|
||||||
b"where" => parse_where_expr(working_set, &spans[pos..]),
|
b"where" => parse_where_expr(working_set, &spans[pos..]),
|
||||||
#[cfg(feature = "plugin")]
|
#[cfg(feature = "plugin")]
|
||||||
b"register" => {
|
|
||||||
working_set.error(ParseError::BuiltinCommandInPipeline(
|
|
||||||
"register".into(),
|
|
||||||
spans[0],
|
|
||||||
));
|
|
||||||
|
|
||||||
parse_call(working_set, &spans[pos..], spans[0])
|
|
||||||
}
|
|
||||||
#[cfg(feature = "plugin")]
|
|
||||||
b"plugin" => {
|
b"plugin" => {
|
||||||
if spans.len() > 1 && working_set.get_span_contents(spans[1]) == b"use" {
|
if spans.len() > 1 && working_set.get_span_contents(spans[1]) == b"use" {
|
||||||
// only 'plugin use' is banned
|
// only 'plugin use' is banned
|
||||||
|
|
|
@ -340,7 +340,7 @@ where
|
||||||
|
|
||||||
/// Build a [`PluginSignature`] from the signature-related methods on [`PluginCommand`].
|
/// Build a [`PluginSignature`] from the signature-related methods on [`PluginCommand`].
|
||||||
///
|
///
|
||||||
/// This is sent to the engine on `register`.
|
/// This is sent to the engine on `plugin add`.
|
||||||
///
|
///
|
||||||
/// This is not a public API.
|
/// This is not a public API.
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub(crate) const OUTPUT_BUFFER_SIZE: usize = 16384;
|
||||||
/// The API for a Nushell plugin
|
/// The API for a Nushell plugin
|
||||||
///
|
///
|
||||||
/// A plugin defines multiple commands, which are added to the engine when the user calls
|
/// A plugin defines multiple commands, which are added to the engine when the user calls
|
||||||
/// `register`.
|
/// `plugin add`.
|
||||||
///
|
///
|
||||||
/// The plugin must be able to be safely shared between threads, so that multiple invocations can
|
/// The plugin must be able to be safely shared between threads, so that multiple invocations can
|
||||||
/// be run in parallel. If interior mutability is desired, consider synchronization primitives such
|
/// be run in parallel. If interior mutability is desired, consider synchronization primitives such
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub trait RegisteredPlugin: Send + Sync {
|
||||||
fn stop(&self) -> Result<(), ShellError>;
|
fn stop(&self) -> Result<(), ShellError>;
|
||||||
|
|
||||||
/// Stop the plugin and reset any state so that we don't make any assumptions about the plugin
|
/// Stop the plugin and reset any state so that we don't make any assumptions about the plugin
|
||||||
/// next time it launches. This is used on `register`.
|
/// next time it launches. This is used on `plugin add`.
|
||||||
fn reset(&self) -> Result<(), ShellError>;
|
fn reset(&self) -> Result<(), ShellError>;
|
||||||
|
|
||||||
/// Cast the pointer to an [`Any`] so that its concrete type can be retrieved.
|
/// Cast the pointer to an [`Any`] so that its concrete type can be retrieved.
|
||||||
|
|
|
@ -12,7 +12,7 @@ A nushell plugin to convert data to nushell tables.
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
1. compile the binary: `cargo build`
|
1. compile the binary: `cargo build`
|
||||||
2. register plugin(assume it's compiled in ./target/debug/):
|
2. plugin add plugin(assume it's compiled in ./target/debug/):
|
||||||
```
|
```
|
||||||
register ./target/debug/nu_plugin_formats
|
plugin add ./target/debug/nu_plugin_formats
|
||||||
```
|
```
|
||||||
|
|
|
@ -8,6 +8,6 @@ To install:
|
||||||
> cargo install --path .
|
> cargo install --path .
|
||||||
```
|
```
|
||||||
|
|
||||||
To register (from inside Nushell):
|
To add the plugin (from inside Nushell):
|
||||||
```
|
```
|
||||||
> register <path to installed plugin>
|
> plugin add <path to installed plugin>
|
||||||
|
|
|
@ -8,6 +8,6 @@ To install:
|
||||||
cargo install --path .
|
cargo install --path .
|
||||||
```
|
```
|
||||||
|
|
||||||
To register (from inside Nushell):
|
To add the plugin (from inside Nushell):
|
||||||
```
|
```
|
||||||
register <path to installed plugin>
|
> plugin add <path to installed plugin>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
# decode and encode information that is read and written to stdin and stdout
|
# decode and encode information that is read and written to stdin and stdout
|
||||||
#
|
#
|
||||||
# To register the plugin use:
|
# To register the plugin use:
|
||||||
# register <path-to-py-file>
|
# plugin add <path-to-py-file>
|
||||||
#
|
#
|
||||||
# Be careful with the spans. Miette will crash if a span is outside the
|
# Be careful with the spans. Miette will crash if a span is outside the
|
||||||
# size of the contents vector. We strongly suggest using the span found in the
|
# size of the contents vector. We strongly suggest using the span found in the
|
||||||
|
@ -258,4 +258,4 @@ if __name__ == "__main__":
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == "--stdio":
|
if len(sys.argv) == 2 and sys.argv[1] == "--stdio":
|
||||||
plugin()
|
plugin()
|
||||||
else:
|
else:
|
||||||
print("Run me from inside nushell!")
|
print("Run me from inside nushell!")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user