diff --git a/src/cli.rs b/src/cli.rs index c8c283f1c4..dd8f48d0b0 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -479,7 +479,7 @@ fn classify_command( })) } false => match context.get_command(name).as_ref() { - Command::Static(command) => { + Command::Static(_command) => { let arg_list_strings: Vec> = match call.children() { //Some(args) => args.iter().map(|i| i.as_external_arg(source)).collect(), Some(args) => args diff --git a/src/commands.rs b/src/commands.rs index 41b7b81bd9..1813129727 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -46,8 +46,8 @@ crate use autoview::Autoview; crate use cd::Cd; crate use clip::Clip; crate use command::{ - command, static_command, CallInfo, Command, CommandArgs, EvaluatedStaticCommandArgs, - RawCommandArgs, StaticCommand, UnevaluatedCallInfo, + command, static_command, Command, CommandArgs, RawCommandArgs, StaticCommand, + UnevaluatedCallInfo, }; crate use config::Config; crate use get::Get; diff --git a/src/commands/autoview.rs b/src/commands/autoview.rs index 5715491e6b..48ecb0570c 100644 --- a/src/commands/autoview.rs +++ b/src/commands/autoview.rs @@ -1,7 +1,6 @@ use crate::commands::{RawCommandArgs, StaticCommand}; use crate::context::{SourceMap, SpanSource}; use crate::errors::ShellError; -use crate::format::GenericView; use crate::prelude::*; use std::path::Path; @@ -33,7 +32,7 @@ pub fn autoview( mut context: RunnableContext, raw: RawCommandArgs, ) -> Result { - let stream = async_stream_block! { + Ok(OutputStream::new(async_stream_block! { let input = context.input.drain_vec().await; if input.len() > 0 { @@ -60,9 +59,7 @@ pub fn autoview( // } } } - }; - - Ok(OutputStream::new(stream)) + })) } fn equal_shapes(input: &Vec>) -> bool { diff --git a/src/commands/clip.rs b/src/commands/clip.rs index 3601b76f27..b0fe940408 100644 --- a/src/commands/clip.rs +++ b/src/commands/clip.rs @@ -35,7 +35,7 @@ pub fn clip( let stream = async_stream_block! { let values: Vec> = input.values.collect().await; - inner_clip(values, name); + inner_clip(values, name).await; }; let stream: BoxStream<'static, ReturnValue> = stream.boxed(); diff --git a/src/commands/command.rs b/src/commands/command.rs index 5b8ee7de82..3223d01029 100644 --- a/src/commands/command.rs +++ b/src/commands/command.rs @@ -159,18 +159,6 @@ impl CommandArgs { } } -pub struct SinkContext { - pub input: Vec>, - pub env: Arc>, - pub name: Option, -} - -pub struct SinkArgs { - args: T, - context: SinkContext, - callback: fn(T, SinkContext) -> Result<(), ShellError>, -} - pub struct RunnableContext { pub input: InputStream, pub env: Arc>, @@ -412,12 +400,6 @@ impl Command { } } - pub fn is_sink(&self) -> bool { - match self { - Command::Static(..) => false, - } - } - pub fn signature(&self) -> Signature { match self { Command::Static(command) => command.signature(), diff --git a/src/commands/plugin.rs b/src/commands/plugin.rs index 902f4bbef1..3224f63103 100644 --- a/src/commands/plugin.rs +++ b/src/commands/plugin.rs @@ -3,7 +3,6 @@ use crate::errors::ShellError; use crate::parser::registry; use crate::prelude::*; use derive_new::new; -use futures_async_stream::async_stream_block; use serde::{self, Deserialize, Serialize}; use std::io::prelude::*; use std::io::BufReader; @@ -60,38 +59,6 @@ impl StaticCommand for PluginCommand { } } -#[derive(new)] -pub struct PluginSink { - path: String, - config: registry::Signature, -} - -impl StaticCommand for PluginSink { - fn run( - &self, - args: CommandArgs, - registry: &CommandRegistry, - ) -> Result { - let path = self.path.clone(); - - let stream = async_stream_block! { - sink_plugin(path, args).await; - }; - - let stream: BoxStream<'static, ReturnValue> = stream.boxed(); - - Ok(OutputStream::from(stream)) - } - - fn name(&self) -> &str { - &self.config.name - } - - fn signature(&self) -> registry::Signature { - self.config.clone() - } -} - pub fn filter_plugin( path: String, args: CommandArgs, @@ -207,22 +174,3 @@ pub fn filter_plugin( Ok(stream.to_output_stream()) } - -pub async fn sink_plugin(path: String, args: CommandArgs) -> Result { - //use subprocess::Exec; - let input: Vec> = args.input.values.collect().await; - let request = JsonRpc::new("sink", (args.call_info, input)); - let request_raw = serde_json::to_string(&request).unwrap(); - let mut tmpfile = tempfile::NamedTempFile::new()?; - let _ = writeln!(tmpfile, "{}", request_raw); - let _ = tmpfile.flush(); - - let mut child = std::process::Command::new(path) - .arg(tmpfile.path()) - .spawn() - .expect("Failed to spawn child process"); - - let _ = child.wait(); - - Ok(OutputStream::empty()) -} diff --git a/src/commands/rm.rs b/src/commands/rm.rs index 8bc17573e1..fb2b19ae3c 100644 --- a/src/commands/rm.rs +++ b/src/commands/rm.rs @@ -1,9 +1,7 @@ -use crate::commands::{EvaluatedStaticCommandArgs, StaticCommand}; +use crate::commands::StaticCommand; use crate::errors::ShellError; use crate::parser::hir::SyntaxType; -use crate::parser::registry::{NamedType, PositionalType}; use crate::prelude::*; -use indexmap::IndexMap; use std::path::PathBuf; pub struct Remove; diff --git a/src/commands/save.rs b/src/commands/save.rs index dae51c9f00..86be95404e 100644 --- a/src/commands/save.rs +++ b/src/commands/save.rs @@ -4,10 +4,10 @@ use crate::commands::to_toml::value_to_toml_value; use crate::commands::to_yaml::value_to_yaml_value; use crate::commands::StaticCommand; use crate::errors::ShellError; -use crate::object::{Primitive, Value}; +use crate::object::Value; use crate::parser::Spanned; use crate::prelude::*; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; pub struct Save; diff --git a/src/commands/vtable.rs b/src/commands/vtable.rs index 6ff1367d34..a60a877654 100644 --- a/src/commands/vtable.rs +++ b/src/commands/vtable.rs @@ -24,7 +24,7 @@ impl StaticCommand for VTable { } } -pub fn vtable(args: VTableArgs, context: RunnableContext) -> Result { +pub fn vtable(_args: VTableArgs, context: RunnableContext) -> Result { let stream = async_stream_block! { let input = context.input.into_vec().await; diff --git a/src/context.rs b/src/context.rs index 9348e41840..01a1e6b650 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,5 +1,5 @@ -use crate::commands::{CallInfo, Command, StaticCommand, UnevaluatedCallInfo}; -use crate::parser::{hir, registry, Span}; +use crate::commands::{Command, UnevaluatedCallInfo}; +use crate::parser::{hir, Span}; use crate::prelude::*; use derive_new::new; diff --git a/src/format.rs b/src/format.rs index be835ea76e..ae43c6f8a9 100644 --- a/src/format.rs +++ b/src/format.rs @@ -7,6 +7,7 @@ crate mod vtable; use crate::prelude::*; crate use entries::EntriesView; +#[allow(unused)] crate use generic::GenericView; crate use table::TableView; crate use vtable::VTableView; diff --git a/src/object.rs b/src/object.rs index f094c63a17..bf8ffb6860 100644 --- a/src/object.rs +++ b/src/object.rs @@ -6,6 +6,7 @@ crate mod into; crate mod process; crate mod types; +#[allow(unused)] crate use base::{Block, Primitive, Switch, Value}; crate use dict::{Dictionary, SpannedDictBuilder}; crate use files::dir_entry_dict; diff --git a/src/object/base.rs b/src/object/base.rs index db534d46af..b4350b7d9e 100644 --- a/src/object/base.rs +++ b/src/object/base.rs @@ -492,16 +492,6 @@ impl Value { } } - crate fn as_pair(&self) -> Result<(Spanned, Spanned), ShellError> { - match self { - Value::List(list) if list.len() == 2 => Ok((list[0].clone(), list[1].clone())), - other => Err(ShellError::string(format!( - "Expected pair, got {:?}", - other - ))), - } - } - crate fn as_string(&self) -> Result { match self { Value::Primitive(Primitive::String(s)) => Ok(s.clone()), @@ -529,17 +519,6 @@ impl Value { } } - crate fn as_block(&self) -> Result { - match self { - Value::Block(block) => Ok(block.clone()), - // TODO: this should definitely be more general with better errors - other => Err(ShellError::string(format!( - "Expected block, got {:?}", - other - ))), - } - } - crate fn is_true(&self) -> bool { match self { Value::Primitive(Primitive::Boolean(true)) => true, diff --git a/src/object/types.rs b/src/object/types.rs index 5ee3784d45..d20586f8b6 100644 --- a/src/object/types.rs +++ b/src/object/types.rs @@ -14,7 +14,7 @@ pub trait ExtractType: Sized { impl ExtractType for T { default fn extract(_value: &Spanned) -> Result { - let name = unsafe { std::intrinsics::type_name::() }; + let name = std::intrinsics::type_name::(); Err(ShellError::unimplemented(format!( " ExtractType for {}", name @@ -32,7 +32,7 @@ impl ExtractType for T { impl ExtractType for Vec> { fn extract(value: &Spanned) -> Result { - let name = unsafe { std::intrinsics::type_name::() }; + let name = std::intrinsics::type_name::(); trace!(" Extracting {:?} for Vec<{}>", value, name); match value.item() { @@ -69,8 +69,8 @@ impl ExtractType for Vec> { impl ExtractType for (T, U) { fn extract(value: &Spanned) -> Result<(T, U), ShellError> { - let t_name = unsafe { std::intrinsics::type_name::() }; - let u_name = unsafe { std::intrinsics::type_name::() }; + let t_name = std::intrinsics::type_name::(); + let u_name = std::intrinsics::type_name::(); trace!("Extracting {:?} for ({}, {})", value, t_name, u_name); @@ -98,7 +98,7 @@ impl ExtractType for (T, U) { impl ExtractType for Option { fn extract(value: &Spanned) -> Result, ShellError> { - let name = unsafe { std::intrinsics::type_name::() }; + let name = std::intrinsics::type_name::(); trace!("