mirror of
https://github.com/nushell/nushell.git
synced 2025-01-05 05:50:14 +01:00
plugin feature flag
This commit is contained in:
parent
dfb846dec6
commit
12eed1f98a
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -395,6 +395,7 @@ dependencies = [
|
|||||||
"nu-json",
|
"nu-json",
|
||||||
"nu-parser",
|
"nu-parser",
|
||||||
"nu-path",
|
"nu-path",
|
||||||
|
"nu-plugin",
|
||||||
"nu-protocol",
|
"nu-protocol",
|
||||||
"nu-table",
|
"nu-table",
|
||||||
"nu-term-grid",
|
"nu-term-grid",
|
||||||
@ -668,7 +669,6 @@ dependencies = [
|
|||||||
"nu-json",
|
"nu-json",
|
||||||
"nu-parser",
|
"nu-parser",
|
||||||
"nu-path",
|
"nu-path",
|
||||||
"nu-plugin",
|
|
||||||
"nu-protocol",
|
"nu-protocol",
|
||||||
"nu-table",
|
"nu-table",
|
||||||
"nu-term-grid",
|
"nu-term-grid",
|
||||||
|
@ -26,12 +26,17 @@ nu-json = { path="./crates/nu-json" }
|
|||||||
nu-parser = { path="./crates/nu-parser" }
|
nu-parser = { path="./crates/nu-parser" }
|
||||||
nu-path = { path="./crates/nu-path" }
|
nu-path = { path="./crates/nu-path" }
|
||||||
nu-protocol = { path = "./crates/nu-protocol" }
|
nu-protocol = { path = "./crates/nu-protocol" }
|
||||||
|
nu-plugin = { path = "./crates/nu-plugin", optional = true }
|
||||||
nu-table = { path = "./crates/nu-table" }
|
nu-table = { path = "./crates/nu-table" }
|
||||||
nu-term-grid = { path = "./crates/nu-term-grid" }
|
nu-term-grid = { path = "./crates/nu-term-grid" }
|
||||||
miette = "3.0.0"
|
miette = "3.0.0"
|
||||||
ctrlc = "3.2.1"
|
ctrlc = "3.2.1"
|
||||||
# mimalloc = { version = "*", default-features = false }
|
# mimalloc = { version = "*", default-features = false }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
plugin = ["nu-plugin", "nu-parser/plugin", "nu-command/plugin"]
|
||||||
|
default = ["plugin"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3.2.0"
|
tempfile = "3.2.0"
|
||||||
assert_cmd = "1.0.7"
|
assert_cmd = "1.0.7"
|
||||||
|
@ -13,7 +13,6 @@ nu-protocol = { path = "../nu-protocol" }
|
|||||||
nu-table = { path = "../nu-table" }
|
nu-table = { path = "../nu-table" }
|
||||||
nu-term-grid = { path = "../nu-term-grid" }
|
nu-term-grid = { path = "../nu-term-grid" }
|
||||||
nu-parser = { path = "../nu-parser" }
|
nu-parser = { path = "../nu-parser" }
|
||||||
nu-plugin = { path = "../nu-plugin" }
|
|
||||||
|
|
||||||
trash = { version = "1.3.0", optional = true }
|
trash = { version = "1.3.0", optional = true }
|
||||||
unicode-segmentation = "1.8.0"
|
unicode-segmentation = "1.8.0"
|
||||||
@ -34,3 +33,4 @@ titlecase = "1.1.0"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
trash-support = ["trash"]
|
trash-support = ["trash"]
|
||||||
|
plugin = ["nu-parser/plugin"]
|
||||||
|
@ -9,8 +9,6 @@ mod hide;
|
|||||||
mod if_;
|
mod if_;
|
||||||
mod let_;
|
mod let_;
|
||||||
mod module;
|
mod module;
|
||||||
mod register;
|
|
||||||
mod run_plugin;
|
|
||||||
mod source;
|
mod source;
|
||||||
mod use_;
|
mod use_;
|
||||||
|
|
||||||
@ -25,7 +23,11 @@ pub use hide::Hide;
|
|||||||
pub use if_::If;
|
pub use if_::If;
|
||||||
pub use let_::Let;
|
pub use let_::Let;
|
||||||
pub use module::Module;
|
pub use module::Module;
|
||||||
pub use register::Register;
|
|
||||||
pub use run_plugin::RunPlugin;
|
|
||||||
pub use source::Source;
|
pub use source::Source;
|
||||||
pub use use_::Use;
|
pub use use_::Use;
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
|
mod register;
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
|
pub use register::Register;
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
use nu_protocol::ast::Call;
|
|
||||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
|
||||||
use nu_protocol::{PipelineData, Signature};
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct RunPlugin;
|
|
||||||
|
|
||||||
impl Command for RunPlugin {
|
|
||||||
fn name(&self) -> &str {
|
|
||||||
"run_plugin"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
|
||||||
"test for plugin encoding"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn signature(&self) -> nu_protocol::Signature {
|
|
||||||
Signature::build("run_plugin")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run(
|
|
||||||
&self,
|
|
||||||
_context: &EngineState,
|
|
||||||
_stack: &mut Stack,
|
|
||||||
_call: &Call,
|
|
||||||
_input: PipelineData,
|
|
||||||
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
|
||||||
Ok(PipelineData::new())
|
|
||||||
}
|
|
||||||
}
|
|
@ -73,10 +73,8 @@ pub fn create_default_context() -> EngineState {
|
|||||||
Mv,
|
Mv,
|
||||||
ParEach,
|
ParEach,
|
||||||
Ps,
|
Ps,
|
||||||
Register,
|
|
||||||
Range,
|
Range,
|
||||||
Rm,
|
Rm,
|
||||||
RunPlugin,
|
|
||||||
Select,
|
Select,
|
||||||
Size,
|
Size,
|
||||||
Split,
|
Split,
|
||||||
@ -94,6 +92,9 @@ pub fn create_default_context() -> EngineState {
|
|||||||
Zip
|
Zip
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
|
bind_command!(Register);
|
||||||
|
|
||||||
// This is a WIP proof of concept
|
// This is a WIP proof of concept
|
||||||
bind_command!(ListGitBranches, Git, GitCheckout, Source);
|
bind_command!(ListGitBranches, Git, GitCheckout, Source);
|
||||||
|
|
||||||
|
@ -7,4 +7,7 @@ edition = "2018"
|
|||||||
miette = "3.0.0"
|
miette = "3.0.0"
|
||||||
thiserror = "1.0.29"
|
thiserror = "1.0.29"
|
||||||
nu-protocol = { path = "../nu-protocol"}
|
nu-protocol = { path = "../nu-protocol"}
|
||||||
nu-plugin = { path = "../nu-plugin"}
|
nu-plugin = { path = "../nu-plugin", optional=true}
|
||||||
|
|
||||||
|
[features]
|
||||||
|
plugin = ["nu-plugin"]
|
||||||
|
@ -11,6 +11,9 @@ pub use flatten::{flatten_block, FlatShape};
|
|||||||
pub use lex::{lex, Token, TokenContents};
|
pub use lex::{lex, Token, TokenContents};
|
||||||
pub use lite_parse::{lite_parse, LiteBlock};
|
pub use lite_parse::{lite_parse, LiteBlock};
|
||||||
pub use parse_keywords::{
|
pub use parse_keywords::{
|
||||||
parse_alias, parse_def, parse_def_predecl, parse_let, parse_module, parse_plugin, parse_use,
|
parse_alias, parse_def, parse_def_predecl, parse_let, parse_module, parse_use,
|
||||||
};
|
};
|
||||||
pub use parser::{find_captures_in_expr, parse, Import, VarDecl};
|
pub use parser::{find_captures_in_expr, parse, Import, VarDecl};
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
|
pub use parse_keywords::parse_plugin;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use nu_plugin::plugin::{get_signature, PluginDeclaration};
|
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
ast::{Block, Call, Expr, Expression, ImportPattern, ImportPatternMember, Pipeline, Statement},
|
ast::{Block, Call, Expr, Expression, ImportPattern, ImportPatternMember, Pipeline, Statement},
|
||||||
engine::StateWorkingSet,
|
engine::StateWorkingSet,
|
||||||
@ -6,6 +5,9 @@ use nu_protocol::{
|
|||||||
};
|
};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
|
use nu_plugin::plugin::{get_signature, PluginDeclaration};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
lex, lite_parse,
|
lex, lite_parse,
|
||||||
parser::{
|
parser::{
|
||||||
@ -925,6 +927,7 @@ pub fn parse_source(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
pub fn parse_plugin(
|
pub fn parse_plugin(
|
||||||
working_set: &mut StateWorkingSet,
|
working_set: &mut StateWorkingSet,
|
||||||
spans: &[Span],
|
spans: &[Span],
|
||||||
|
@ -15,10 +15,12 @@ use nu_protocol::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::parse_keywords::{
|
use crate::parse_keywords::{
|
||||||
parse_alias, parse_def, parse_def_predecl, parse_hide, parse_let, parse_module, parse_plugin,
|
parse_alias, parse_def, parse_def_predecl, parse_hide, parse_let, parse_module, parse_use,
|
||||||
parse_use,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
|
use crate::parse_keywords::parse_plugin;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum Import {}
|
pub enum Import {}
|
||||||
|
|
||||||
@ -3007,6 +3009,7 @@ pub fn parse_statement(
|
|||||||
Some(ParseError::UnexpectedKeyword("export".into(), spans[0])),
|
Some(ParseError::UnexpectedKeyword("export".into(), spans[0])),
|
||||||
),
|
),
|
||||||
b"hide" => parse_hide(working_set, spans),
|
b"hide" => parse_hide(working_set, spans),
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
b"register" => parse_plugin(working_set, spans),
|
b"register" => parse_plugin(working_set, spans),
|
||||||
_ => {
|
_ => {
|
||||||
let (expr, err) = parse_expression(working_set, spans, true);
|
let (expr, err) = parse_expression(working_set, spans, true);
|
||||||
|
@ -138,7 +138,7 @@ impl Command for PluginDeclaration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
"plugin name plus arguments"
|
self.signature.usage.as_str()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run(
|
fn run(
|
||||||
|
Loading…
Reference in New Issue
Block a user