diff --git a/crates/nu-cli/src/commands/commandline/commandline_.rs b/crates/nu-cli/src/commands/commandline/commandline_.rs index fd0fc2bac101..3a6669497912 100644 --- a/crates/nu-cli/src/commands/commandline/commandline_.rs +++ b/crates/nu-cli/src/commands/commandline/commandline_.rs @@ -1,9 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; use unicode_segmentation::UnicodeSegmentation; #[derive(Clone)] diff --git a/crates/nu-cli/src/commands/commandline/edit.rs b/crates/nu-cli/src/commands/commandline/edit.rs index 85aebab16460..f5048d7172a8 100644 --- a/crates/nu-cli/src/commands/commandline/edit.rs +++ b/crates/nu-cli/src/commands/commandline/edit.rs @@ -1,9 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cli/src/commands/commandline/get_cursor.rs b/crates/nu-cli/src/commands/commandline/get_cursor.rs index e0458bc03162..a50f7e564e39 100644 --- a/crates/nu-cli/src/commands/commandline/get_cursor.rs +++ b/crates/nu-cli/src/commands/commandline/get_cursor.rs @@ -1,8 +1,4 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::command_prelude::*; use unicode_segmentation::UnicodeSegmentation; #[derive(Clone)] diff --git a/crates/nu-cli/src/commands/commandline/set_cursor.rs b/crates/nu-cli/src/commands/commandline/set_cursor.rs index bff05a683409..ddb18dcde364 100644 --- a/crates/nu-cli/src/commands/commandline/set_cursor.rs +++ b/crates/nu-cli/src/commands/commandline/set_cursor.rs @@ -1,9 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use unicode_segmentation::UnicodeSegmentation; #[derive(Clone)] diff --git a/crates/nu-cli/src/commands/default_context.rs b/crates/nu-cli/src/commands/default_context.rs index cd5025fdc7c1..0c1c459c209d 100644 --- a/crates/nu-cli/src/commands/default_context.rs +++ b/crates/nu-cli/src/commands/default_context.rs @@ -1,6 +1,5 @@ -use nu_protocol::engine::{EngineState, StateWorkingSet}; - use crate::commands::*; +use nu_protocol::engine::{EngineState, StateWorkingSet}; pub fn add_cli_context(mut engine_state: EngineState) -> EngineState { let delta = { diff --git a/crates/nu-cli/src/commands/history/history_.rs b/crates/nu-cli/src/commands/history/history_.rs index b45b30147c8f..4572aaba351d 100644 --- a/crates/nu-cli/src/commands/history/history_.rs +++ b/crates/nu-cli/src/commands/history/history_.rs @@ -1,10 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, HistoryFileFormat, IntoInterruptiblePipelineData, PipelineData, - ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::HistoryFileFormat; use reedline::{ FileBackedHistory, History as ReedlineHistory, HistoryItem, SearchDirection, SearchQuery, SqliteBackedHistory, diff --git a/crates/nu-cli/src/commands/history/history_session.rs b/crates/nu-cli/src/commands/history/history_session.rs index 9f423f64178d..5e68e4786525 100644 --- a/crates/nu-cli/src/commands/history/history_session.rs +++ b/crates/nu-cli/src/commands/history/history_session.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct HistorySession; diff --git a/crates/nu-cli/src/commands/keybindings.rs b/crates/nu-cli/src/commands/keybindings.rs index 9c1bd0820732..469c0f96cd9e 100644 --- a/crates/nu-cli/src/commands/keybindings.rs +++ b/crates/nu-cli/src/commands/keybindings.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Keybindings; diff --git a/crates/nu-cli/src/commands/keybindings_default.rs b/crates/nu-cli/src/commands/keybindings_default.rs index c853dd7495ac..1fbd6140856e 100644 --- a/crates/nu-cli/src/commands/keybindings_default.rs +++ b/crates/nu-cli/src/commands/keybindings_default.rs @@ -1,8 +1,4 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::command_prelude::*; use reedline::get_reedline_default_keybindings; #[derive(Clone)] diff --git a/crates/nu-cli/src/commands/keybindings_list.rs b/crates/nu-cli/src/commands/keybindings_list.rs index 391be2efa75a..72399c773a48 100644 --- a/crates/nu-cli/src/commands/keybindings_list.rs +++ b/crates/nu-cli/src/commands/keybindings_list.rs @@ -1,9 +1,4 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, - Value, -}; +use nu_engine::command_prelude::*; use reedline::{ get_reedline_edit_commands, get_reedline_keybinding_modifiers, get_reedline_keycodes, get_reedline_prompt_edit_modes, get_reedline_reedline_events, diff --git a/crates/nu-cli/src/commands/keybindings_listen.rs b/crates/nu-cli/src/commands/keybindings_listen.rs index 9049fc4d034b..1cb443e36098 100644 --- a/crates/nu-cli/src/commands/keybindings_listen.rs +++ b/crates/nu-cli/src/commands/keybindings_listen.rs @@ -1,12 +1,7 @@ -use crossterm::execute; -use crossterm::QueueableCommand; -use crossterm::{event::Event, event::KeyCode, event::KeyEvent, terminal}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, - Value, +use crossterm::{ + event::Event, event::KeyCode, event::KeyEvent, execute, terminal, QueueableCommand, }; +use nu_engine::command_prelude::*; use std::io::{stdout, Write}; #[derive(Clone)] diff --git a/crates/nu-cli/src/completions/completer.rs b/crates/nu-cli/src/completions/completer.rs index d11f84c77250..15abe6f61178 100644 --- a/crates/nu-cli/src/completions/completer.rs +++ b/crates/nu-cli/src/completions/completer.rs @@ -5,14 +5,13 @@ use crate::completions::{ use nu_color_config::{color_record_to_nustyle, lookup_ansi_color_style}; use nu_engine::eval_block; use nu_parser::{flatten_pipeline_element, parse, FlatShape}; -use nu_protocol::debugger::WithoutDebug; use nu_protocol::{ + debugger::WithoutDebug, engine::{EngineState, Stack, StateWorkingSet}, BlockId, PipelineData, Span, Value, }; use reedline::{Completer as ReedlineCompleter, Suggestion}; -use std::str; -use std::sync::Arc; +use std::{str, sync::Arc}; use super::base::{SemanticSuggestion, SuggestionKind}; diff --git a/crates/nu-cli/src/completions/completion_common.rs b/crates/nu-cli/src/completions/completion_common.rs index 9b5a022fd24d..5f927976a27f 100644 --- a/crates/nu-cli/src/completions/completion_common.rs +++ b/crates/nu-cli/src/completions/completion_common.rs @@ -2,11 +2,15 @@ use crate::completions::{matches, CompletionOptions}; use nu_ansi_term::Style; use nu_engine::env_to_string; use nu_path::home_dir; -use nu_protocol::engine::{EngineState, Stack}; -use nu_protocol::{engine::StateWorkingSet, Span}; +use nu_protocol::{ + engine::{EngineState, Stack, StateWorkingSet}, + Span, +}; use nu_utils::get_ls_colors; -use std::ffi::OsStr; -use std::path::{is_separator, Component, Path, PathBuf, MAIN_SEPARATOR as SEP}; +use std::{ + ffi::OsStr, + path::{is_separator, Component, Path, PathBuf, MAIN_SEPARATOR as SEP}, +}; fn complete_rec( partial: &[String], diff --git a/crates/nu-cli/src/completions/completion_options.rs b/crates/nu-cli/src/completions/completion_options.rs index e686da27add6..6ed81d42ce83 100644 --- a/crates/nu-cli/src/completions/completion_options.rs +++ b/crates/nu-cli/src/completions/completion_options.rs @@ -1,8 +1,7 @@ -use std::fmt::Display; - use fuzzy_matcher::{skim::SkimMatcherV2, FuzzyMatcher}; use nu_parser::trim_quotes_str; use nu_protocol::CompletionAlgorithm; +use std::fmt::Display; #[derive(Copy, Clone)] pub enum SortBy { diff --git a/crates/nu-cli/src/completions/custom_completions.rs b/crates/nu-cli/src/completions/custom_completions.rs index f0411fa4c34b..7dac283fba45 100644 --- a/crates/nu-cli/src/completions/custom_completions.rs +++ b/crates/nu-cli/src/completions/custom_completions.rs @@ -1,17 +1,16 @@ -use crate::completions::{Completer, CompletionOptions, MatchAlgorithm, SortBy}; +use crate::completions::{ + completer::map_value_completions, Completer, CompletionOptions, MatchAlgorithm, + SemanticSuggestion, SortBy, +}; use nu_engine::eval_call; -use nu_protocol::debugger::WithoutDebug; use nu_protocol::{ ast::{Argument, Call, Expr, Expression}, + debugger::WithoutDebug, engine::{EngineState, Stack, StateWorkingSet}, PipelineData, Span, Type, Value, }; use nu_utils::IgnoreCaseExt; -use std::collections::HashMap; -use std::sync::Arc; - -use super::base::SemanticSuggestion; -use super::completer::map_value_completions; +use std::{collections::HashMap, sync::Arc}; pub struct CustomCompletion { engine_state: Arc, diff --git a/crates/nu-cli/src/completions/directory_completions.rs b/crates/nu-cli/src/completions/directory_completions.rs index 7db10b730858..f8ab2f400eb5 100644 --- a/crates/nu-cli/src/completions/directory_completions.rs +++ b/crates/nu-cli/src/completions/directory_completions.rs @@ -8,8 +8,10 @@ use nu_protocol::{ levenshtein_distance, Span, }; use reedline::Suggestion; -use std::path::{Path, MAIN_SEPARATOR as SEP}; -use std::sync::Arc; +use std::{ + path::{Path, MAIN_SEPARATOR as SEP}, + sync::Arc, +}; use super::SemanticSuggestion; diff --git a/crates/nu-cli/src/completions/file_completions.rs b/crates/nu-cli/src/completions/file_completions.rs index f63318e11366..d862975f8692 100644 --- a/crates/nu-cli/src/completions/file_completions.rs +++ b/crates/nu-cli/src/completions/file_completions.rs @@ -9,8 +9,10 @@ use nu_protocol::{ }; use nu_utils::IgnoreCaseExt; use reedline::Suggestion; -use std::path::{Path, MAIN_SEPARATOR as SEP}; -use std::sync::Arc; +use std::{ + path::{Path, MAIN_SEPARATOR as SEP}, + sync::Arc, +}; use super::SemanticSuggestion; diff --git a/crates/nu-cli/src/completions/flag_completions.rs b/crates/nu-cli/src/completions/flag_completions.rs index f0d361051072..07cd89dc0a63 100644 --- a/crates/nu-cli/src/completions/flag_completions.rs +++ b/crates/nu-cli/src/completions/flag_completions.rs @@ -4,7 +4,6 @@ use nu_protocol::{ engine::StateWorkingSet, Span, }; - use reedline::Suggestion; use super::SemanticSuggestion; diff --git a/crates/nu-cli/src/completions/variable_completions.rs b/crates/nu-cli/src/completions/variable_completions.rs index 4d85e6730f73..826e1e412ac3 100644 --- a/crates/nu-cli/src/completions/variable_completions.rs +++ b/crates/nu-cli/src/completions/variable_completions.rs @@ -1,15 +1,13 @@ -use crate::completions::{Completer, CompletionOptions}; +use crate::completions::{ + Completer, CompletionOptions, MatchAlgorithm, SemanticSuggestion, SuggestionKind, +}; use nu_engine::{column::get_columns, eval_variable}; use nu_protocol::{ engine::{EngineState, Stack, StateWorkingSet}, Span, Value, }; - use reedline::Suggestion; -use std::str; -use std::sync::Arc; - -use super::{MatchAlgorithm, SemanticSuggestion, SuggestionKind}; +use std::{str, sync::Arc}; #[derive(Clone)] pub struct VariableCompletion { diff --git a/crates/nu-cli/src/config_files.rs b/crates/nu-cli/src/config_files.rs index 794d5dcc0390..e965b25f3761 100644 --- a/crates/nu-cli/src/config_files.rs +++ b/crates/nu-cli/src/config_files.rs @@ -1,9 +1,10 @@ use crate::util::eval_source; #[cfg(feature = "plugin")] use nu_path::canonicalize_with; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::report_error; -use nu_protocol::{HistoryFileFormat, PipelineData}; +use nu_protocol::{ + engine::{EngineState, Stack, StateWorkingSet}, + report_error, HistoryFileFormat, PipelineData, +}; #[cfg(feature = "plugin")] use nu_protocol::{ParseError, Spanned}; #[cfg(feature = "plugin")] diff --git a/crates/nu-cli/src/eval_cmds.rs b/crates/nu-cli/src/eval_cmds.rs index 9b37aed33efe..e29eb6f5f42e 100644 --- a/crates/nu-cli/src/eval_cmds.rs +++ b/crates/nu-cli/src/eval_cmds.rs @@ -2,12 +2,10 @@ use log::info; use miette::Result; use nu_engine::{convert_env_values, eval_block}; use nu_parser::parse; -use nu_protocol::debugger::WithoutDebug; -use nu_protocol::engine::Stack; -use nu_protocol::report_error; use nu_protocol::{ - engine::{EngineState, StateWorkingSet}, - PipelineData, Spanned, Value, + debugger::WithoutDebug, + engine::{EngineState, Stack, StateWorkingSet}, + report_error, PipelineData, Spanned, Value, }; /// Run a command (or commands) given to us by the user diff --git a/crates/nu-cli/src/eval_file.rs b/crates/nu-cli/src/eval_file.rs index f2b6e0b5204c..68d16abf308c 100644 --- a/crates/nu-cli/src/eval_file.rs +++ b/crates/nu-cli/src/eval_file.rs @@ -1,21 +1,17 @@ -use std::sync::Arc; - use crate::util::eval_source; -use log::info; -use log::trace; +use log::{info, trace}; use miette::{IntoDiagnostic, Result}; -use nu_engine::eval_block; -use nu_engine::{convert_env_values, current_dir}; +use nu_engine::{convert_env_values, current_dir, eval_block}; use nu_parser::parse; use nu_path::canonicalize_with; -use nu_protocol::debugger::WithoutDebug; -use nu_protocol::report_error; use nu_protocol::{ ast::Call, + debugger::WithoutDebug, engine::{EngineState, Stack, StateWorkingSet}, - Config, PipelineData, ShellError, Span, Value, + report_error, Config, PipelineData, ShellError, Span, Value, }; use nu_utils::stdout_write_all_and_flush; +use std::sync::Arc; /// Main function used when a file path is found as argument for nu pub fn evaluate_file( diff --git a/crates/nu-cli/src/menus/help_completions.rs b/crates/nu-cli/src/menus/help_completions.rs index 90270415f689..b8bdaad43505 100644 --- a/crates/nu-cli/src/menus/help_completions.rs +++ b/crates/nu-cli/src/menus/help_completions.rs @@ -2,8 +2,7 @@ use nu_engine::documentation::get_flags_section; use nu_protocol::{engine::EngineState, levenshtein_distance}; use nu_utils::IgnoreCaseExt; use reedline::{Completer, Suggestion}; -use std::fmt::Write; -use std::sync::Arc; +use std::{fmt::Write, sync::Arc}; pub struct NuHelpCompleter(Arc); diff --git a/crates/nu-cli/src/menus/menu_completions.rs b/crates/nu-cli/src/menus/menu_completions.rs index ef7facc90006..c853d7f77ba0 100644 --- a/crates/nu-cli/src/menus/menu_completions.rs +++ b/crates/nu-cli/src/menus/menu_completions.rs @@ -1,6 +1,6 @@ use nu_engine::eval_block; -use nu_protocol::debugger::WithoutDebug; use nu_protocol::{ + debugger::WithoutDebug, engine::{EngineState, Stack}, IntoPipelineData, Span, Value, }; diff --git a/crates/nu-cli/src/nu_highlight.rs b/crates/nu-cli/src/nu_highlight.rs index 02dc64e9cbdd..07084c6258b0 100644 --- a/crates/nu-cli/src/nu_highlight.rs +++ b/crates/nu-cli/src/nu_highlight.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Type, Value}; +use nu_engine::command_prelude::*; use reedline::{Highlighter, StyledText}; #[derive(Clone)] diff --git a/crates/nu-cli/src/print.rs b/crates/nu-cli/src/print.rs index b213780ded55..2e58114d8b4b 100644 --- a/crates/nu-cli/src/print.rs +++ b/crates/nu-cli/src/print.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, - Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Print; diff --git a/crates/nu-cli/src/prompt.rs b/crates/nu-cli/src/prompt.rs index 4ec0e677f90c..0ecdae1aaf9d 100644 --- a/crates/nu-cli/src/prompt.rs +++ b/crates/nu-cli/src/prompt.rs @@ -1,13 +1,11 @@ use crate::prompt_update::{POST_PROMPT_MARKER, PRE_PROMPT_MARKER}; #[cfg(windows)] use nu_utils::enable_vt_processing; -use reedline::DefaultPrompt; -use { - reedline::{ - Prompt, PromptEditMode, PromptHistorySearch, PromptHistorySearchStatus, PromptViMode, - }, - std::borrow::Cow, +use reedline::{ + DefaultPrompt, Prompt, PromptEditMode, PromptHistorySearch, PromptHistorySearchStatus, + PromptViMode, }; +use std::borrow::Cow; /// Nushell prompt definition #[derive(Clone)] diff --git a/crates/nu-cli/src/prompt_update.rs b/crates/nu-cli/src/prompt_update.rs index 83fa75b0da3c..26389ae81e2e 100644 --- a/crates/nu-cli/src/prompt_update.rs +++ b/crates/nu-cli/src/prompt_update.rs @@ -1,11 +1,9 @@ use crate::NushellPrompt; use log::trace; use nu_engine::get_eval_subexpression; - -use nu_protocol::report_error; use nu_protocol::{ engine::{EngineState, Stack, StateWorkingSet}, - Config, PipelineData, Value, + report_error, Config, PipelineData, Value, }; use reedline::Prompt; diff --git a/crates/nu-cli/src/reedline_config.rs b/crates/nu-cli/src/reedline_config.rs index a3c929a381c8..5f0f9d22708a 100644 --- a/crates/nu-cli/src/reedline_config.rs +++ b/crates/nu-cli/src/reedline_config.rs @@ -3,9 +3,9 @@ use crossterm::event::{KeyCode, KeyModifiers}; use nu_color_config::{color_record_to_nustyle, lookup_ansi_color_style}; use nu_engine::eval_block; use nu_parser::parse; -use nu_protocol::debugger::WithoutDebug; use nu_protocol::{ create_menus, + debugger::WithoutDebug, engine::{EngineState, Stack, StateWorkingSet}, extract_value, Config, EditBindings, ParsedKeybinding, ParsedMenu, PipelineData, Record, ShellError, Span, Value, @@ -1311,9 +1311,8 @@ fn extract_char(value: &Value, config: &Config) -> Result { #[cfg(test)] mod test { - use nu_protocol::record; - use super::*; + use nu_protocol::record; #[test] fn test_send_event() { diff --git a/crates/nu-cli/src/repl.rs b/crates/nu-cli/src/repl.rs index 8fc00cc887cd..3792e06af7b4 100644 --- a/crates/nu-cli/src/repl.rs +++ b/crates/nu-cli/src/repl.rs @@ -9,8 +9,10 @@ use crate::{ use crossterm::cursor::SetCursorStyle; use log::{error, trace, warn}; use miette::{ErrReport, IntoDiagnostic, Result}; -use nu_cmd_base::util::get_guaranteed_cwd; -use nu_cmd_base::{hook::eval_hook, util::get_editor}; +use nu_cmd_base::{ + hook::eval_hook, + util::{get_editor, get_guaranteed_cwd}, +}; use nu_color_config::StyleComputer; use nu_engine::{convert_env_values, env_to_strings}; use nu_parser::{lex, parse, trim_quotes_str}; @@ -31,8 +33,7 @@ use std::{ env::temp_dir, io::{self, IsTerminal, Write}, panic::{catch_unwind, AssertUnwindSafe}, - path::Path, - path::PathBuf, + path::{Path, PathBuf}, sync::{atomic::Ordering, Arc}, time::{Duration, Instant}, }; diff --git a/crates/nu-cli/src/syntax_highlight.rs b/crates/nu-cli/src/syntax_highlight.rs index 712faea6f2ba..20addeab108d 100644 --- a/crates/nu-cli/src/syntax_highlight.rs +++ b/crates/nu-cli/src/syntax_highlight.rs @@ -3,9 +3,11 @@ use nu_ansi_term::Style; use nu_color_config::{get_matching_brackets_style, get_shape_color}; use nu_engine::env; use nu_parser::{flatten_block, parse, FlatShape}; -use nu_protocol::ast::{Argument, Block, Expr, Expression, PipelineRedirection, RecordItem}; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::{Config, Span}; +use nu_protocol::{ + ast::{Argument, Block, Expr, Expression, PipelineRedirection, RecordItem}, + engine::{EngineState, Stack, StateWorkingSet}, + Config, Span, +}; use reedline::{Highlighter, StyledText}; use std::sync::Arc; diff --git a/crates/nu-cli/src/util.rs b/crates/nu-cli/src/util.rs index 46553b1c1f83..8ff4ef35ea96 100644 --- a/crates/nu-cli/src/util.rs +++ b/crates/nu-cli/src/util.rs @@ -1,13 +1,11 @@ use nu_cmd_base::hook::eval_hook; use nu_engine::{eval_block, eval_block_with_early_return}; use nu_parser::{escape_quote_string, lex, parse, unescape_unquote_string, Token, TokenContents}; -use nu_protocol::debugger::WithoutDebug; -use nu_protocol::engine::StateWorkingSet; use nu_protocol::{ - engine::{EngineState, Stack}, - print_if_stream, PipelineData, ShellError, Span, Value, + debugger::WithoutDebug, + engine::{EngineState, Stack, StateWorkingSet}, + print_if_stream, report_error, report_error_new, PipelineData, ShellError, Span, Value, }; -use nu_protocol::{report_error, report_error_new}; #[cfg(windows)] use nu_utils::enable_vt_processing; use nu_utils::utils::perf; diff --git a/crates/nu-cli/tests/completions.rs b/crates/nu-cli/tests/completions.rs index 2914ee503e77..ee60efe2554c 100644 --- a/crates/nu-cli/tests/completions.rs +++ b/crates/nu-cli/tests/completions.rs @@ -1,12 +1,11 @@ pub mod support; -use std::path::PathBuf; - use nu_cli::NuCompleter; use nu_parser::parse; use nu_protocol::engine::StateWorkingSet; use reedline::{Completer, Suggestion}; use rstest::{fixture, rstest}; +use std::path::PathBuf; use support::{ completions_helpers::{new_partial_engine, new_quote_engine}, file, folder, match_suggestions, new_engine, diff --git a/crates/nu-cli/tests/support/completions_helpers.rs b/crates/nu-cli/tests/support/completions_helpers.rs index 1c6b125c757c..f7ae31c7f4d7 100644 --- a/crates/nu-cli/tests/support/completions_helpers.rs +++ b/crates/nu-cli/tests/support/completions_helpers.rs @@ -1,15 +1,14 @@ -use std::path::PathBuf; - use nu_engine::eval_block; use nu_parser::parse; -use nu_protocol::debugger::WithoutDebug; use nu_protocol::{ + debugger::WithoutDebug, engine::{EngineState, Stack, StateWorkingSet}, eval_const::create_nu_constant, PipelineData, ShellError, Span, Value, NU_VARIABLE_ID, }; use nu_test_support::fs; use reedline::Suggestion; +use std::path::PathBuf; const SEP: char = std::path::MAIN_SEPARATOR; diff --git a/crates/nu-cmd-base/src/hook.rs b/crates/nu-cmd-base/src/hook.rs index cdb2bed5f3cf..e4dafdc997d3 100644 --- a/crates/nu-cmd-base/src/hook.rs +++ b/crates/nu-cmd-base/src/hook.rs @@ -1,13 +1,14 @@ -use std::sync::Arc; - use crate::util::get_guaranteed_cwd; use miette::Result; use nu_engine::{eval_block, eval_block_with_early_return}; use nu_parser::parse; -use nu_protocol::cli_error::{report_error, report_error_new}; -use nu_protocol::debugger::WithoutDebug; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::{BlockId, PipelineData, PositionalArg, ShellError, Span, Type, Value, VarId}; +use nu_protocol::{ + cli_error::{report_error, report_error_new}, + debugger::WithoutDebug, + engine::{EngineState, Stack, StateWorkingSet}, + BlockId, PipelineData, PositionalArg, ShellError, Span, Type, Value, VarId, +}; +use std::sync::Arc; pub fn eval_env_change_hook( env_change_hook: Option, diff --git a/crates/nu-cmd-base/src/input_handler.rs b/crates/nu-cmd-base/src/input_handler.rs index 9787822858d7..d81193e19091 100644 --- a/crates/nu-cmd-base/src/input_handler.rs +++ b/crates/nu-cmd-base/src/input_handler.rs @@ -1,7 +1,5 @@ -use nu_protocol::ast::CellPath; -use nu_protocol::{PipelineData, ShellError, Span, Value}; -use std::sync::atomic::AtomicBool; -use std::sync::Arc; +use nu_protocol::{ast::CellPath, PipelineData, ShellError, Span, Value}; +use std::sync::{atomic::AtomicBool, Arc}; pub trait CmdArgument { fn take_cell_paths(&mut self) -> Option>; diff --git a/crates/nu-cmd-base/src/util.rs b/crates/nu-cmd-base/src/util.rs index da1e6dbfb743..44f782492b51 100644 --- a/crates/nu-cmd-base/src/util.rs +++ b/crates/nu-cmd-base/src/util.rs @@ -1,8 +1,7 @@ -use nu_protocol::report_error; use nu_protocol::{ ast::RangeInclusion, engine::{EngineState, Stack, StateWorkingSet}, - Range, ShellError, Span, Value, + report_error, Range, ShellError, Span, Value, }; use std::path::PathBuf; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/append.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/append.rs index 3607420f45cd..c0be67ed6e28 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/append.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/append.rs @@ -1,11 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; - -use super::super::values::{Axis, Column, NuDataFrame}; +use crate::dataframe::values::{Axis, Column, NuDataFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct AppendDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/cast.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/cast.rs index 1abf6f62a8f6..c170f8db8aa1 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/cast.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/cast.rs @@ -1,12 +1,6 @@ -use crate::dataframe::values::{str_to_dtype, NuExpression, NuLazyFrame}; - -use super::super::values::NuDataFrame; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use crate::dataframe::values::{str_to_dtype, NuDataFrame, NuExpression, NuLazyFrame}; +use nu_engine::command_prelude::*; + use polars::prelude::*; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/columns.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/columns.rs index b071ce2bab63..c9167659b5de 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/columns.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/columns.rs @@ -1,9 +1,5 @@ -use super::super::values::NuDataFrame; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::NuDataFrame; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ColumnsDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/drop.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/drop.rs index 3fee7721d3be..8f9d086947e9 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/drop.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/drop.rs @@ -1,12 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; - -use super::super::values::utils::convert_columns; -use super::super::values::{Column, NuDataFrame}; +use crate::dataframe::values::{utils::convert_columns, Column, NuDataFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct DropDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/drop_duplicates.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/drop_duplicates.rs index 12004032ecee..b2ae6f7cfce9 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/drop_duplicates.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/drop_duplicates.rs @@ -1,13 +1,7 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; -use polars::prelude::UniqueKeepStrategy; +use crate::dataframe::values::{utils::convert_columns_string, Column, NuDataFrame}; +use nu_engine::command_prelude::*; -use super::super::values::utils::convert_columns_string; -use super::super::values::{Column, NuDataFrame}; +use polars::prelude::UniqueKeepStrategy; #[derive(Clone)] pub struct DropDuplicates; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/drop_nulls.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/drop_nulls.rs index b0a229cd71a2..25a390742677 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/drop_nulls.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/drop_nulls.rs @@ -1,12 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; - -use super::super::values::utils::convert_columns_string; -use super::super::values::{Column, NuDataFrame}; +use crate::dataframe::values::{utils::convert_columns_string, Column, NuDataFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct DropNulls; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/dtypes.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/dtypes.rs index 1fcf3ba7caf6..a572a495514a 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/dtypes.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/dtypes.rs @@ -1,9 +1,5 @@ -use super::super::values::{Column, NuDataFrame}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct DataTypes; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/dummies.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/dummies.rs index f4fb542f1a15..f47f65a00485 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/dummies.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/dummies.rs @@ -1,10 +1,6 @@ -use super::super::values::NuDataFrame; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, -}; +use crate::dataframe::values::NuDataFrame; +use nu_engine::command_prelude::*; + use polars::{prelude::*, series::Series}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/filter_with.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/filter_with.rs index c04e3d3bd4f8..3793945181bb 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/filter_with.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/filter_with.rs @@ -1,14 +1,7 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; -use polars::prelude::LazyFrame; - -use crate::dataframe::values::{NuExpression, NuLazyFrame}; +use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame}; +use nu_engine::command_prelude::*; -use super::super::values::{Column, NuDataFrame}; +use polars::prelude::LazyFrame; #[derive(Clone)] pub struct FilterWith; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/first.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/first.rs index aa92712eeaeb..70160b3005f4 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/first.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/first.rs @@ -1,10 +1,5 @@ -use super::super::values::{Column, NuDataFrame, NuExpression}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame, NuExpression}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct FirstDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/get.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/get.rs index 236b6c0eee03..e8cf33786409 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/get.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/get.rs @@ -1,13 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; - -use crate::dataframe::values::utils::convert_columns_string; - -use super::super::values::{Column, NuDataFrame}; +use crate::dataframe::values::{utils::convert_columns_string, Column, NuDataFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct GetDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/last.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/last.rs index 4258d1700358..a0a188471d2a 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/last.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/last.rs @@ -1,10 +1,5 @@ -use super::super::values::{utils::DEFAULT_ROWS, Column, NuDataFrame, NuExpression}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use crate::dataframe::values::{utils::DEFAULT_ROWS, Column, NuDataFrame, NuExpression}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct LastDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/list.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/list.rs index 0fe412ffe9ce..1cee69418089 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/list.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/list.rs @@ -1,10 +1,5 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Value, -}; - use crate::dataframe::values::NuDataFrame; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ListDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/melt.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/melt.rs index 07cc85d26589..6379e9270e98 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/melt.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/melt.rs @@ -1,14 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, - Value, -}; - -use crate::dataframe::values::utils::convert_columns_string; - -use super::super::values::{Column, NuDataFrame}; +use crate::dataframe::values::{utils::convert_columns_string, Column, NuDataFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct MeltDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/open.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/open.rs index 99ef78792f1a..8571e41b399c 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/open.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/open.rs @@ -1,21 +1,12 @@ -use crate::dataframe::values::NuSchema; - -use super::super::values::{NuDataFrame, NuLazyFrame}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; - -use std::{fs::File, io::BufReader, path::PathBuf}; +use crate::dataframe::values::{NuDataFrame, NuLazyFrame, NuSchema}; +use nu_engine::command_prelude::*; use polars::prelude::{ CsvEncoding, CsvReader, IpcReader, JsonFormat, JsonReader, LazyCsvReader, LazyFileListReader, LazyFrame, ParallelStrategy, ParquetReader, ScanArgsIpc, ScanArgsParquet, SerReader, }; - use polars_io::avro::AvroReader; +use std::{fs::File, io::BufReader, path::PathBuf}; #[derive(Clone)] pub struct OpenDataFrame; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/query_df.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/query_df.rs index 82128909bae0..7215f0adbeef 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/query_df.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/query_df.rs @@ -1,12 +1,8 @@ -use super::super::values::NuDataFrame; -use crate::dataframe::values::Column; -use crate::dataframe::{eager::SQLContext, values::NuLazyFrame}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, +use crate::dataframe::{ + eager::SQLContext, + values::{Column, NuDataFrame, NuLazyFrame}, }; +use nu_engine::command_prelude::*; // attribution: // sql_context.rs, and sql_expr.rs were copied from polars-sql. thank you. diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/rename.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/rename.rs index 61db1c8c2f3a..5167a0c9685c 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/rename.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/rename.rs @@ -1,13 +1,8 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, +use crate::dataframe::{ + utils::extract_strings, + values::{Column, NuDataFrame, NuLazyFrame}, }; - -use crate::dataframe::{utils::extract_strings, values::NuLazyFrame}; - -use super::super::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct RenameDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/sample.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/sample.rs index 67c0e6a0dc1d..2387cca489fa 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/sample.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/sample.rs @@ -1,13 +1,7 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, -}; -use polars::prelude::NamedFrom; -use polars::series::Series; +use crate::dataframe::values::NuDataFrame; +use nu_engine::command_prelude::*; -use super::super::values::NuDataFrame; +use polars::{prelude::NamedFrom, series::Series}; #[derive(Clone)] pub struct SampleDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/schema.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/schema.rs index 7028d15e7c48..cf887482bd27 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/schema.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/schema.rs @@ -1,10 +1,5 @@ -use super::super::values::NuDataFrame; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::NuDataFrame; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SchemaDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/shape.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/shape.rs index a139ae8504a5..6e5e7fa9d3f9 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/shape.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/shape.rs @@ -1,12 +1,5 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; - -use crate::dataframe::values::Column; - -use super::super::values::NuDataFrame; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ShapeDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/slice.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/slice.rs index d1f73ffc221c..48906cba2c35 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/slice.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/slice.rs @@ -1,13 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; - -use crate::dataframe::values::Column; - -use super::super::values::NuDataFrame; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SliceDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/summary.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/summary.rs index dafb29afeefb..845929a52dc8 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/summary.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/summary.rs @@ -1,11 +1,6 @@ -use super::super::values::{Column, NuDataFrame}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; use polars::{ chunked_array::ChunkedArray, prelude::{ diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/take.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/take.rs index e7699898e59a..406dd1d624dd 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/take.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/take.rs @@ -1,14 +1,7 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; -use polars::prelude::DataType; - -use crate::dataframe::values::Column; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; -use super::super::values::NuDataFrame; +use polars::prelude::DataType; #[derive(Clone)] pub struct TakeDF; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/to_arrow.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/to_arrow.rs index 159818451fd1..66f13121bf50 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/to_arrow.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/to_arrow.rs @@ -1,14 +1,8 @@ -use std::{fs::File, path::PathBuf}; +use crate::dataframe::values::NuDataFrame; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; use polars::prelude::{IpcWriter, SerWriter}; - -use super::super::values::NuDataFrame; +use std::{fs::File, path::PathBuf}; #[derive(Clone)] pub struct ToArrow; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/to_avro.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/to_avro.rs index eb56ea7fcb0d..e5e5c6fae1ac 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/to_avro.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/to_avro.rs @@ -1,15 +1,11 @@ -use std::{fs::File, path::PathBuf}; +use crate::dataframe::values::NuDataFrame; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, +use polars_io::{ + avro::{AvroCompression, AvroWriter}, + SerWriter, }; -use polars_io::avro::{AvroCompression, AvroWriter}; -use polars_io::SerWriter; - -use super::super::values::NuDataFrame; +use std::{fs::File, path::PathBuf}; #[derive(Clone)] pub struct ToAvro; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/to_csv.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/to_csv.rs index 55f86bcea564..d85bed515025 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/to_csv.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/to_csv.rs @@ -1,14 +1,8 @@ -use std::{fs::File, path::PathBuf}; +use crate::dataframe::values::NuDataFrame; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; use polars::prelude::{CsvWriter, SerWriter}; - -use super::super::values::NuDataFrame; +use std::{fs::File, path::PathBuf}; #[derive(Clone)] pub struct ToCSV; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/to_df.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/to_df.rs index d9431bfbcc9e..d768c7a74241 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/to_df.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/to_df.rs @@ -1,13 +1,6 @@ -use crate::dataframe::values::NuSchema; +use crate::dataframe::values::{Column, NuDataFrame, NuSchema}; +use nu_engine::command_prelude::*; -use super::super::values::{Column, NuDataFrame}; - -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; use polars::prelude::*; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/to_json_lines.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/to_json_lines.rs index ad8fc01b2713..5875f17107b4 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/to_json_lines.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/to_json_lines.rs @@ -1,14 +1,8 @@ -use std::{fs::File, io::BufWriter, path::PathBuf}; +use crate::dataframe::values::NuDataFrame; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; use polars::prelude::{JsonWriter, SerWriter}; - -use super::super::values::NuDataFrame; +use std::{fs::File, io::BufWriter, path::PathBuf}; #[derive(Clone)] pub struct ToJsonLines; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/to_nu.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/to_nu.rs index cf4cde260f6d..e032269b099a 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/to_nu.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/to_nu.rs @@ -1,13 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; - -use crate::dataframe::values::NuExpression; - -use super::super::values::NuDataFrame; +use crate::dataframe::values::{NuDataFrame, NuExpression}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ToNu; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/to_parquet.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/to_parquet.rs index d3043e039dbe..ce6419a9ac70 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/to_parquet.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/to_parquet.rs @@ -1,14 +1,8 @@ -use std::{fs::File, path::PathBuf}; +use crate::dataframe::values::NuDataFrame; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; use polars::prelude::ParquetWriter; - -use super::super::values::NuDataFrame; +use std::{fs::File, path::PathBuf}; #[derive(Clone)] pub struct ToParquet; diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/with_column.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/with_column.rs index c3c2661b5997..52ceefceb423 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/with_column.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/with_column.rs @@ -1,11 +1,5 @@ -use super::super::values::{Column, NuDataFrame}; -use crate::dataframe::values::{NuExpression, NuLazyFrame}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct WithColumn; diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/alias.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/alias.rs index 0e20ff7f8634..9d36100276ca 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/alias.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/alias.rs @@ -1,11 +1,5 @@ -use super::super::values::NuExpression; - -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use crate::dataframe::values::NuExpression; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ExprAlias; diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/arg_where.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/arg_where.rs index af826f9cd105..49c13c3f445e 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/arg_where.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/arg_where.rs @@ -1,10 +1,6 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use polars::prelude::arg_where; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/col.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/col.rs index e717510819f3..1520ef995dc8 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/col.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/col.rs @@ -1,10 +1,6 @@ use crate::dataframe::values::NuExpression; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use polars::prelude::col; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/concat_str.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/concat_str.rs index 5a80af4855b6..28f9bbda71a4 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/concat_str.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/concat_str.rs @@ -1,10 +1,6 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use polars::prelude::concat_str; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/datepart.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/datepart.rs index 30542ea0b083..60913c0dc6c6 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/datepart.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/datepart.rs @@ -1,14 +1,7 @@ -use super::super::values::NuExpression; - -use crate::dataframe::values::{Column, NuDataFrame}; +use crate::dataframe::values::{Column, NuDataFrame, NuExpression}; use chrono::{DateTime, FixedOffset}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, - Value, -}; +use nu_engine::command_prelude::*; + use polars::{ datatypes::{DataType, TimeUnit}, prelude::NamedFrom, diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/expressions_macro.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/expressions_macro.rs index 6a5585cdc81e..b2d79be010a4 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/expressions_macro.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/expressions_macro.rs @@ -2,11 +2,7 @@ /// All of these expressions have an identical body and only require /// to have a change in the name, description and expression function use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; // The structs defined in this file are structs that form part of other commands // since they share a similar name diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/is_in.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/is_in.rs index 06994fd50bb2..1579ba0e2007 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/is_in.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/is_in.rs @@ -1,10 +1,6 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use polars::prelude::{lit, DataType}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/lit.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/lit.rs index 536cd66c46b0..8610a59048e6 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/lit.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/lit.rs @@ -1,10 +1,5 @@ use crate::dataframe::values::NuExpression; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ExprLit; diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/otherwise.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/otherwise.rs index 0125d3bded86..0ba507f97f7e 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/otherwise.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/otherwise.rs @@ -1,10 +1,5 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuWhen}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ExprOtherwise; diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/quantile.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/quantile.rs index 60cab60739ce..d82a0faf0a89 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/quantile.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/quantile.rs @@ -1,10 +1,6 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use polars::prelude::{lit, QuantileInterpolOptions}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/when.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/when.rs index 1248acb3bd8c..d70fd0082561 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/when.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/when.rs @@ -1,10 +1,6 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuWhen}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use polars::prelude::when; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/aggregate.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/aggregate.rs index bbbe710073cb..715c3d156b86 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/aggregate.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/aggregate.rs @@ -1,11 +1,6 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame, NuLazyGroupBy}; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; use polars::{datatypes::DataType, prelude::Expr}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/collect.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/collect.rs index 9f919049b24d..411f56364082 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/collect.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/collect.rs @@ -1,11 +1,5 @@ -use crate::dataframe::values::{Column, NuDataFrame}; - -use super::super::values::NuLazyFrame; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame, NuLazyFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct LazyCollect; diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/explode.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/explode.rs index c8e4ed3686f0..8e32ae804061 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/explode.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/explode.rs @@ -1,10 +1,5 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct LazyExplode; @@ -46,7 +41,7 @@ impl Command for LazyExplode { result: Some( NuDataFrame::try_from_columns(vec![ Column::new( - "id".to_string(), + "id".to_string(), vec![ Value::test_int(1), Value::test_int(1), @@ -54,7 +49,7 @@ impl Command for LazyExplode { Value::test_int(2), ]), Column::new( - "name".to_string(), + "name".to_string(), vec![ Value::test_string("Mercy"), Value::test_string("Mercy"), @@ -62,7 +57,7 @@ impl Command for LazyExplode { Value::test_string("Bob"), ]), Column::new( - "hobbies".to_string(), + "hobbies".to_string(), vec![ Value::test_string("Cycling"), Value::test_string("Knitting"), @@ -79,7 +74,7 @@ impl Command for LazyExplode { result: Some( NuDataFrame::try_from_columns(vec![ Column::new( - "hobbies".to_string(), + "hobbies".to_string(), vec![ Value::test_string("Cycling"), Value::test_string("Knitting"), diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/fetch.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/fetch.rs index aad5c812e689..6ba75aa97049 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/fetch.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/fetch.rs @@ -1,11 +1,5 @@ -use super::super::values::NuLazyFrame; -use crate::dataframe::values::{Column, NuDataFrame}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame, NuLazyFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct LazyFetch; diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_nan.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_nan.rs index 7febcb115ff2..a9a1eb159048 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_nan.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_nan.rs @@ -1,10 +1,5 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct LazyFillNA; diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_null.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_null.rs index 0acf433532b4..b3d35d2b8def 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_null.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_null.rs @@ -1,10 +1,5 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct LazyFillNull; diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/filter.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/filter.rs index 1c4f68c19cf9..5635a77e884e 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/filter.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/filter.rs @@ -1,11 +1,5 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame}; - -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct LazyFilter; diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/flatten.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/flatten.rs index 1facfc1d297a..602dcbcee355 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/flatten.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/flatten.rs @@ -1,12 +1,6 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; - -use crate::dataframe::values::{Column, NuDataFrame}; - use super::explode::explode; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct LazyFlatten; @@ -48,7 +42,7 @@ Example { result: Some( NuDataFrame::try_from_columns(vec![ Column::new( - "id".to_string(), + "id".to_string(), vec![ Value::test_int(1), Value::test_int(1), @@ -56,7 +50,7 @@ Example { Value::test_int(2), ]), Column::new( - "name".to_string(), + "name".to_string(), vec![ Value::test_string("Mercy"), Value::test_string("Mercy"), @@ -64,7 +58,7 @@ Example { Value::test_string("Bob"), ]), Column::new( - "hobbies".to_string(), + "hobbies".to_string(), vec![ Value::test_string("Cycling"), Value::test_string("Knitting"), @@ -81,7 +75,7 @@ Example { result: Some( NuDataFrame::try_from_columns(vec![ Column::new( - "hobbies".to_string(), + "hobbies".to_string(), vec![ Value::test_string("Cycling"), Value::test_string("Knitting"), diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/groupby.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/groupby.rs index 01c27671ae2c..c31d563eb6a9 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/groupby.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/groupby.rs @@ -1,10 +1,6 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame, NuLazyGroupBy}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use polars::prelude::Expr; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/join.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/join.rs index 232d7228f18e..81f9db4b05cf 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/join.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/join.rs @@ -1,10 +1,6 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use polars::prelude::{Expr, JoinType}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/macro_commands.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/macro_commands.rs index c3fc73fae126..89655b8e3f4d 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/macro_commands.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/macro_commands.rs @@ -2,11 +2,7 @@ /// All of these commands have an identical body and only require /// to have a change in the name, description and function use crate::dataframe::values::{Column, NuDataFrame, NuLazyFrame}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; macro_rules! lazy_command { ($command: ident, $name: expr, $desc: expr, $examples: expr, $func: ident, $test: ident) => { diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/quantile.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/quantile.rs index 1882477f123d..d17a444f49bf 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/quantile.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/quantile.rs @@ -1,10 +1,6 @@ use crate::dataframe::values::{Column, NuDataFrame, NuLazyFrame}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use polars::prelude::{lit, QuantileInterpolOptions}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/select.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/select.rs index 614c029892e2..b4f01bdc0778 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/select.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/select.rs @@ -1,11 +1,6 @@ use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame}; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; #[derive(Clone)] pub struct LazySelect; diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/sort_by_expr.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/sort_by_expr.rs index a81cbfd5d424..7f8ad2631763 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/sort_by_expr.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/sort_by_expr.rs @@ -1,11 +1,5 @@ -use super::super::values::NuLazyFrame; -use crate::dataframe::values::{Column, NuDataFrame, NuExpression}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct LazySortBy; diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/to_lazy.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/to_lazy.rs index 32b716352465..857be750d312 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/to_lazy.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/to_lazy.rs @@ -1,13 +1,5 @@ -use crate::dataframe::values::NuSchema; - -use super::super::values::{NuDataFrame, NuLazyFrame}; - -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use crate::dataframe::values::{NuDataFrame, NuLazyFrame, NuSchema}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ToLazyFrame; diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/all_false.rs b/crates/nu-cmd-dataframe/src/dataframe/series/all_false.rs index cbe17096119b..66921e793cc7 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/all_false.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/all_false.rs @@ -1,10 +1,5 @@ -use super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct AllFalse; diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/all_true.rs b/crates/nu-cmd-dataframe/src/dataframe/series/all_true.rs index 564519489d01..16b4a9edd9fd 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/all_true.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/all_true.rs @@ -1,10 +1,5 @@ -use super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct AllTrue; diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/arg_max.rs b/crates/nu-cmd-dataframe/src/dataframe/series/arg_max.rs index 9f35af120683..d7539401ab3b 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/arg_max.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/arg_max.rs @@ -1,10 +1,5 @@ -use super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{ArgAgg, IntoSeries, NewChunkedArray, UInt32Chunked}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/arg_min.rs b/crates/nu-cmd-dataframe/src/dataframe/series/arg_min.rs index 9a56efc0e3b9..1b685d65b4e0 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/arg_min.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/arg_min.rs @@ -1,10 +1,5 @@ -use super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{ArgAgg, IntoSeries, NewChunkedArray, UInt32Chunked}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/cumulative.rs b/crates/nu-cmd-dataframe/src/dataframe/series/cumulative.rs index a4e0730b4db8..c32875e87b6b 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/cumulative.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/cumulative.rs @@ -1,12 +1,6 @@ -use super::super::values::{Column, NuDataFrame}; - -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, - Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; + use polars::prelude::{DataType, IntoSeries}; use polars_ops::prelude::{cum_max, cum_min, cum_sum}; diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/as_date.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/as_date.rs index 9a42927e7e8d..b4060575723e 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/as_date.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/as_date.rs @@ -1,11 +1,6 @@ -use super::super::super::values::NuDataFrame; +use crate::dataframe::values::NuDataFrame; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, -}; use polars::prelude::{IntoSeries, StringMethods}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/as_datetime.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/as_datetime.rs index c7b590b22d91..6ee979b06971 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/as_datetime.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/as_datetime.rs @@ -1,12 +1,7 @@ -use super::super::super::values::{Column, NuDataFrame}; - +use crate::dataframe::values::{Column, NuDataFrame}; use chrono::DateTime; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use polars::prelude::{IntoSeries, StringMethods, TimeUnit}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_day.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_day.rs index e441289a3173..9187219d7aea 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_day.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_day.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{DatetimeMethods, IntoSeries}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_hour.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_hour.rs index 88402a459e41..ba0584304745 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_hour.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_hour.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{DatetimeMethods, IntoSeries}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_minute.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_minute.rs index acf5777a0895..902ed61d567e 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_minute.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_minute.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{DatetimeMethods, IntoSeries}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_month.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_month.rs index 820eee58d25d..077d5afc1e94 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_month.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_month.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{DatetimeMethods, IntoSeries}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_nanosecond.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_nanosecond.rs index 4279ac741ba4..1543e3108238 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_nanosecond.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_nanosecond.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{DatetimeMethods, IntoSeries}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_ordinal.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_ordinal.rs index 3b38d7ff0073..b77ebbc14cd8 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_ordinal.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_ordinal.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{DatetimeMethods, IntoSeries}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_second.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_second.rs index fa01c66d0e9a..e039bcc01012 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_second.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_second.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{DatetimeMethods, IntoSeries}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_week.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_week.rs index cc5f60fad0a6..1a1bc2c12d05 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_week.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_week.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{DatetimeMethods, IntoSeries}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_weekday.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_weekday.rs index 24aa90ace324..b5cf1b3197af 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_weekday.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_weekday.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{DatetimeMethods, IntoSeries}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_year.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_year.rs index 22c216ae4b5b..1ec351594994 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_year.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_year.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{DatetimeMethods, IntoSeries}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_sort.rs b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_sort.rs index e74c64c5574c..bf28cbac58b4 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_sort.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_sort.rs @@ -1,11 +1,6 @@ -use super::super::super::values::{Column, NuDataFrame}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; use polars::prelude::{IntoSeries, SortOptions}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_true.rs b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_true.rs index 042e17b112c7..106e95f5ea77 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_true.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_true.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{arg_where, col, IntoLazy}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_unique.rs b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_unique.rs index 65af1e6974cd..6b69518cbafe 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_unique.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_unique.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::IntoSeries; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/set_with_idx.rs b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/set_with_idx.rs index d2bc5a623e38..307ef4d5c3c0 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/set_with_idx.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/set_with_idx.rs @@ -1,11 +1,6 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; + use polars::prelude::{ChunkSet, DataType, IntoSeries}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_duplicated.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_duplicated.rs index 4c0c1490e69f..b28f977b47b0 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_duplicated.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_duplicated.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::IntoSeries; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_in.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_in.rs index 5b7a4e208ddc..0792d3fddfe6 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_in.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_in.rs @@ -1,11 +1,6 @@ -use super::super::super::values::{Column, NuDataFrame}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; use polars::prelude::{is_in, IntoSeries}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_not_null.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_not_null.rs index 8015e5016c3c..ce66f6987701 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_not_null.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_not_null.rs @@ -1,9 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame, NuExpression}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame, NuExpression}; +use nu_engine::command_prelude::*; use polars::prelude::IntoSeries; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_null.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_null.rs index 7ba779072224..d7921da347df 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_null.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_null.rs @@ -1,9 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame, NuExpression}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame, NuExpression}; +use nu_engine::command_prelude::*; use polars::prelude::IntoSeries; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_unique.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_unique.rs index daf477c9c122..8e313abca79f 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_unique.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_unique.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::IntoSeries; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/not.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/not.rs index 448cf15e1fe7..081a3c3b23bc 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/not.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/not.rs @@ -1,9 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::IntoSeries; use std::ops::Not; diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/set.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/set.rs index a296eb3c9061..4dacb7117b40 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/set.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/set.rs @@ -1,11 +1,6 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; + use polars::prelude::{ChunkSet, DataType, IntoSeries}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/n_null.rs b/crates/nu-cmd-dataframe/src/dataframe/series/n_null.rs index 79f27c0e41b0..6c9909da0786 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/n_null.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/n_null.rs @@ -1,10 +1,5 @@ -use super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct NNull; diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/n_unique.rs b/crates/nu-cmd-dataframe/src/dataframe/series/n_unique.rs index ad39a12ef245..b23ab4e20dbb 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/n_unique.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/n_unique.rs @@ -1,9 +1,5 @@ -use super::super::values::{Column, NuDataFrame, NuExpression}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame, NuExpression}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct NUnique; diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/rolling.rs b/crates/nu-cmd-dataframe/src/dataframe/series/rolling.rs index 059c6c56a2ab..b659462298a3 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/rolling.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/rolling.rs @@ -1,12 +1,6 @@ -use super::super::values::{Column, NuDataFrame}; - -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, - Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; + use polars::prelude::{DataType, Duration, IntoSeries, RollingOptionsImpl, SeriesOpsTime}; enum RollType { diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/shift.rs b/crates/nu-cmd-dataframe/src/dataframe/series/shift.rs index 75410097f5c5..bf842840b4c0 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/shift.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/shift.rs @@ -1,13 +1,5 @@ -use crate::dataframe::values::{NuExpression, NuLazyFrame}; - -use super::super::values::{Column, NuDataFrame}; - -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame}; +use nu_engine::command_prelude::*; use polars_plan::prelude::lit; diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/concatenate.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/concatenate.rs index 762a766d9db7..d7589bd3b19d 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/concatenate.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/concatenate.rs @@ -1,11 +1,6 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; + use polars::prelude::{IntoSeries, StringNameSpaceImpl}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/contains.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/contains.rs index 5ebc2dbfc357..9c1d92681ee4 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/contains.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/contains.rs @@ -1,11 +1,6 @@ -use super::super::super::values::{Column, NuDataFrame}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; use polars::prelude::{IntoSeries, StringNameSpaceImpl}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/replace.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/replace.rs index 3f6a89afa20d..d954e20b66e4 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/replace.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/replace.rs @@ -1,11 +1,6 @@ -use super::super::super::values::{Column, NuDataFrame}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; use polars::prelude::{IntoSeries, StringNameSpaceImpl}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/replace_all.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/replace_all.rs index 35f53ca60b88..f329cbca73f1 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/replace_all.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/replace_all.rs @@ -1,11 +1,6 @@ -use super::super::super::values::{Column, NuDataFrame}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; use polars::prelude::{IntoSeries, StringNameSpaceImpl}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/str_lengths.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/str_lengths.rs index 653893d02c6a..6889cef38708 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/str_lengths.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/str_lengths.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{IntoSeries, StringNameSpaceImpl}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/str_slice.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/str_slice.rs index 3f71e0ef753c..6a5c8364c273 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/str_slice.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/str_slice.rs @@ -1,11 +1,6 @@ -use super::super::super::values::{Column, NuDataFrame}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; use polars::{ prelude::{IntoSeries, NamedFrom, StringNameSpaceImpl}, series::Series, diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/strftime.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/strftime.rs index f16c1fe6c3d6..3cdfa84f8e24 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/strftime.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/strftime.rs @@ -1,11 +1,6 @@ -use super::super::super::values::{Column, NuDataFrame}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; use polars::prelude::IntoSeries; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/to_lowercase.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/to_lowercase.rs index 58f12bc2b0d0..2340437e359a 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/to_lowercase.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/to_lowercase.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{IntoSeries, StringNameSpaceImpl}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/to_uppercase.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/to_uppercase.rs index 111c7e40eacc..23378f5dc3b3 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/to_uppercase.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/to_uppercase.rs @@ -1,10 +1,5 @@ -use super::super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::{IntoSeries, StringNameSpaceImpl}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/unique.rs b/crates/nu-cmd-dataframe/src/dataframe/series/unique.rs index fa09052a322c..13012b4fb34d 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/unique.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/unique.rs @@ -1,13 +1,9 @@ -use crate::dataframe::{utils::extract_strings, values::NuLazyFrame}; - -use super::super::values::{Column, NuDataFrame}; - -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, +use crate::dataframe::{ + utils::extract_strings, + values::{Column, NuDataFrame, NuLazyFrame}, }; +use nu_engine::command_prelude::*; + use polars::prelude::{IntoSeries, UniqueKeepStrategy}; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/value_counts.rs b/crates/nu-cmd-dataframe/src/dataframe/series/value_counts.rs index 20930e931ca1..87d3b42b3aa7 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/value_counts.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/value_counts.rs @@ -1,11 +1,5 @@ -use super::super::values::{Column, NuDataFrame}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; - +use crate::dataframe::values::{Column, NuDataFrame}; +use nu_engine::command_prelude::*; use polars::prelude::SeriesMethods; #[derive(Clone)] diff --git a/crates/nu-cmd-dataframe/src/dataframe/stub.rs b/crates/nu-cmd-dataframe/src/dataframe/stub.rs index 6b5c36b03758..2d8cfde4236f 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/stub.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/stub.rs @@ -1,7 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Dfr; diff --git a/crates/nu-cmd-dataframe/src/dataframe/test_dataframe.rs b/crates/nu-cmd-dataframe/src/dataframe/test_dataframe.rs index b668745ec279..d6febf7e43c7 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/test_dataframe.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/test_dataframe.rs @@ -1,16 +1,12 @@ -use nu_engine::eval_block; -use nu_parser::parse; -use nu_protocol::{ - engine::{Command, EngineState, Stack, StateWorkingSet}, - Example, PipelineData, Span, +use super::{ + eager::{SchemaDF, ToDataFrame}, + expressions::ExprCol, + lazy::{LazyCollect, LazyFillNull, ToLazyFrame}, }; - -use super::eager::{SchemaDF, ToDataFrame}; -use super::expressions::ExprCol; -use super::lazy::LazyFillNull; -use super::lazy::{LazyCollect, ToLazyFrame}; use nu_cmd_lang::Let; -use nu_protocol::debugger::WithoutDebug; +use nu_engine::{command_prelude::*, eval_block}; +use nu_parser::parse; +use nu_protocol::{debugger::WithoutDebug, engine::StateWorkingSet}; pub fn test_dataframe(cmds: Vec>) { if cmds.is_empty() { diff --git a/crates/nu-cmd-dataframe/src/dataframe/values/nu_dataframe/conversion.rs b/crates/nu-cmd-dataframe/src/dataframe/values/nu_dataframe/conversion.rs index 22f77fc412a1..7ab339d78dd2 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/values/nu_dataframe/conversion.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/values/nu_dataframe/conversion.rs @@ -1,26 +1,23 @@ -use std::ops::{Deref, DerefMut}; - +use super::{DataFrameValue, NuDataFrame, NuSchema}; use chrono::{DateTime, Duration, FixedOffset, NaiveTime, TimeZone, Utc}; use chrono_tz::Tz; use indexmap::map::{Entry, IndexMap}; -use polars::chunked_array::builder::AnonymousOwnedListBuilder; -use polars::chunked_array::object::builder::ObjectChunkedBuilder; -use polars::chunked_array::ChunkedArray; -use polars::datatypes::AnyValue; -use polars::export::arrow::Either; -use polars::prelude::{ - DataFrame, DataType, DatetimeChunked, Float32Type, Float64Type, Int16Type, Int32Type, - Int64Type, Int8Type, IntoSeries, ListBooleanChunkedBuilder, ListBuilderTrait, - ListPrimitiveChunkedBuilder, ListStringChunkedBuilder, ListType, NamedFrom, NewChunkedArray, - ObjectType, Schema, Series, StructChunked, TemporalMethods, TimeUnit, UInt16Type, UInt32Type, - UInt64Type, UInt8Type, -}; - use nu_protocol::{Record, ShellError, Span, Value}; - -use crate::dataframe::values::NuSchema; - -use super::{DataFrameValue, NuDataFrame}; +use polars::{ + chunked_array::{ + builder::AnonymousOwnedListBuilder, object::builder::ObjectChunkedBuilder, ChunkedArray, + }, + datatypes::AnyValue, + export::arrow::Either, + prelude::{ + DataFrame, DataType, DatetimeChunked, Float32Type, Float64Type, Int16Type, Int32Type, + Int64Type, Int8Type, IntoSeries, ListBooleanChunkedBuilder, ListBuilderTrait, + ListPrimitiveChunkedBuilder, ListStringChunkedBuilder, ListType, NamedFrom, + NewChunkedArray, ObjectType, Schema, Series, StructChunked, TemporalMethods, TimeUnit, + UInt16Type, UInt32Type, UInt64Type, UInt8Type, + }, +}; +use std::ops::{Deref, DerefMut}; const NANOS_PER_DAY: i64 = 86_400_000_000_000; diff --git a/crates/nu-cmd-dataframe/src/dataframe/values/nu_dataframe/mod.rs b/crates/nu-cmd-dataframe/src/dataframe/values/nu_dataframe/mod.rs index 503bf1d5e94a..8f90966fe25f 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/values/nu_dataframe/mod.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/values/nu_dataframe/mod.rs @@ -6,7 +6,8 @@ mod operations; pub use conversion::{Column, ColumnMap}; pub use operations::Axis; -use indexmap::map::IndexMap; +use super::{nu_schema::NuSchema, utils::DEFAULT_ROWS, NuLazyFrame}; +use indexmap::IndexMap; use nu_protocol::{did_you_mean, PipelineData, Record, ShellError, Span, Value}; use polars::prelude::{DataFrame, DataType, IntoLazy, LazyFrame, PolarsObject, Series}; use polars_plan::prelude::{lit, Expr, Null}; @@ -14,8 +15,6 @@ use polars_utils::total_ord::TotalEq; use serde::{Deserialize, Serialize}; use std::{cmp::Ordering, collections::HashSet, fmt::Display, hash::Hasher}; -use super::{nu_schema::NuSchema, utils::DEFAULT_ROWS, NuLazyFrame}; - // DataFrameValue is an encapsulation of Nushell Value that can be used // to define the PolarsObject Trait. The polars object trait allows to // create dataframes with mixed datatypes diff --git a/crates/nu-cmd-dataframe/src/dataframe/values/nu_dataframe/operations.rs b/crates/nu-cmd-dataframe/src/dataframe/values/nu_dataframe/operations.rs index 0835e85f2999..3fbe40806a11 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/values/nu_dataframe/operations.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/values/nu_dataframe/operations.rs @@ -1,12 +1,10 @@ +use super::{ + between_values::{between_dataframes, compute_between_series, compute_series_single_value}, + NuDataFrame, +}; use nu_protocol::{ast::Operator, ShellError, Span, Spanned, Value}; use polars::prelude::{DataFrame, Series}; -use super::between_values::{ - between_dataframes, compute_between_series, compute_series_single_value, -}; - -use super::NuDataFrame; - pub enum Axis { Row, Column, diff --git a/crates/nu-cmd-dataframe/src/dataframe/values/nu_expression/custom_value.rs b/crates/nu-cmd-dataframe/src/dataframe/values/nu_expression/custom_value.rs index 52fdb7f0f18d..7d786c9f75ac 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/values/nu_expression/custom_value.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/values/nu_expression/custom_value.rs @@ -1,11 +1,10 @@ -use std::ops::{Add, Div, Mul, Rem, Sub}; - use super::NuExpression; use nu_protocol::{ ast::{Comparison, Math, Operator}, CustomValue, ShellError, Span, Type, Value, }; use polars::prelude::Expr; +use std::ops::{Add, Div, Mul, Rem, Sub}; // CustomValue implementation for NuDataFrame impl CustomValue for NuExpression { diff --git a/crates/nu-cmd-dataframe/src/dataframe/values/nu_schema.rs b/crates/nu-cmd-dataframe/src/dataframe/values/nu_schema.rs index 662bfae842b9..3c2f689b855b 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/values/nu_schema.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/values/nu_schema.rs @@ -1,7 +1,6 @@ -use std::sync::Arc; - use nu_protocol::{ShellError, Span, Value}; use polars::prelude::{DataType, Field, Schema, SchemaRef, TimeUnit}; +use std::sync::Arc; #[derive(Debug, Clone)] pub struct NuSchema { diff --git a/crates/nu-cmd-extra/src/extra/bits/and.rs b/crates/nu-cmd-extra/src/extra/bits/and.rs index 9b5b1e09bd4f..538cf6e60f98 100644 --- a/crates/nu-cmd-extra/src/extra/bits/and.rs +++ b/crates/nu-cmd-extra/src/extra/bits/and.rs @@ -1,10 +1,5 @@ use super::binary_op; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct BitsAnd; diff --git a/crates/nu-cmd-extra/src/extra/bits/bits_.rs b/crates/nu-cmd-extra/src/extra/bits/bits_.rs index 63664f2a1708..6767d3dd83e8 100644 --- a/crates/nu-cmd-extra/src/extra/bits/bits_.rs +++ b/crates/nu-cmd-extra/src/extra/bits/bits_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Bits; diff --git a/crates/nu-cmd-extra/src/extra/bits/into.rs b/crates/nu-cmd-extra/src/extra/bits/into.rs index 0e63dd85d95f..b5ac5ddaeab4 100644 --- a/crates/nu-cmd-extra/src/extra/bits/into.rs +++ b/crates/nu-cmd-extra/src/extra/bits/into.rs @@ -1,11 +1,6 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; + use num_traits::ToPrimitive; pub struct Arguments { diff --git a/crates/nu-cmd-extra/src/extra/bits/mod.rs b/crates/nu-cmd-extra/src/extra/bits/mod.rs index 5f1998b7caf9..6d1200a6bf7c 100644 --- a/crates/nu-cmd-extra/src/extra/bits/mod.rs +++ b/crates/nu-cmd-extra/src/extra/bits/mod.rs @@ -13,7 +13,6 @@ pub use and::BitsAnd; pub use bits_::Bits; pub use into::BitsInto; pub use not::BitsNot; -use nu_protocol::{ShellError, Value}; pub use or::BitsOr; pub use rotate_left::BitsRol; pub use rotate_right::BitsRor; @@ -21,7 +20,7 @@ pub use shift_left::BitsShl; pub use shift_right::BitsShr; pub use xor::BitsXor; -use nu_protocol::{Span, Spanned}; +use nu_protocol::{ShellError, Span, Spanned, Value}; use std::iter; #[derive(Clone, Copy)] diff --git a/crates/nu-cmd-extra/src/extra/bits/not.rs b/crates/nu-cmd-extra/src/extra/bits/not.rs index 9be083be7dff..e4c344f137f6 100644 --- a/crates/nu-cmd-extra/src/extra/bits/not.rs +++ b/crates/nu-cmd-extra/src/extra/bits/not.rs @@ -1,11 +1,6 @@ use super::{get_number_bytes, NumberBytes}; use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct BitsNot; diff --git a/crates/nu-cmd-extra/src/extra/bits/or.rs b/crates/nu-cmd-extra/src/extra/bits/or.rs index 8b153767c5ef..2352d65c23b8 100644 --- a/crates/nu-cmd-extra/src/extra/bits/or.rs +++ b/crates/nu-cmd-extra/src/extra/bits/or.rs @@ -1,10 +1,5 @@ use super::binary_op; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct BitsOr; diff --git a/crates/nu-cmd-extra/src/extra/bits/rotate_left.rs b/crates/nu-cmd-extra/src/extra/bits/rotate_left.rs index d832ac8f5486..cbd9d17eb5e7 100644 --- a/crates/nu-cmd-extra/src/extra/bits/rotate_left.rs +++ b/crates/nu-cmd-extra/src/extra/bits/rotate_left.rs @@ -1,14 +1,7 @@ use super::{get_input_num_type, get_number_bytes, InputNumType, NumberBytes}; use itertools::Itertools; use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Spanned; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; struct Arguments { signed: bool, diff --git a/crates/nu-cmd-extra/src/extra/bits/rotate_right.rs b/crates/nu-cmd-extra/src/extra/bits/rotate_right.rs index 6f90a8a5b75f..0aea603ce1f8 100644 --- a/crates/nu-cmd-extra/src/extra/bits/rotate_right.rs +++ b/crates/nu-cmd-extra/src/extra/bits/rotate_right.rs @@ -1,14 +1,7 @@ use super::{get_input_num_type, get_number_bytes, InputNumType, NumberBytes}; use itertools::Itertools; use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Spanned; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; struct Arguments { signed: bool, diff --git a/crates/nu-cmd-extra/src/extra/bits/shift_left.rs b/crates/nu-cmd-extra/src/extra/bits/shift_left.rs index f6df810c4445..049408c24a91 100644 --- a/crates/nu-cmd-extra/src/extra/bits/shift_left.rs +++ b/crates/nu-cmd-extra/src/extra/bits/shift_left.rs @@ -1,14 +1,8 @@ use super::{get_input_num_type, get_number_bytes, InputNumType, NumberBytes}; use itertools::Itertools; use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Spanned; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use std::iter; struct Arguments { diff --git a/crates/nu-cmd-extra/src/extra/bits/shift_right.rs b/crates/nu-cmd-extra/src/extra/bits/shift_right.rs index 94fb4cee933b..d66db68ee5fd 100644 --- a/crates/nu-cmd-extra/src/extra/bits/shift_right.rs +++ b/crates/nu-cmd-extra/src/extra/bits/shift_right.rs @@ -1,14 +1,8 @@ use super::{get_input_num_type, get_number_bytes, InputNumType, NumberBytes}; use itertools::Itertools; use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Spanned; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use std::iter; struct Arguments { diff --git a/crates/nu-cmd-extra/src/extra/bits/xor.rs b/crates/nu-cmd-extra/src/extra/bits/xor.rs index 87b55cd3dd7b..65c3be4e1a8e 100644 --- a/crates/nu-cmd-extra/src/extra/bits/xor.rs +++ b/crates/nu-cmd-extra/src/extra/bits/xor.rs @@ -1,10 +1,5 @@ use super::binary_op; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct BitsXor; diff --git a/crates/nu-cmd-extra/src/extra/conversions/fmt.rs b/crates/nu-cmd-extra/src/extra/conversions/fmt.rs index 739beeeec124..54897fd41384 100644 --- a/crates/nu-cmd-extra/src/extra/conversions/fmt.rs +++ b/crates/nu-cmd-extra/src/extra/conversions/fmt.rs @@ -1,10 +1,5 @@ use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Fmt; diff --git a/crates/nu-cmd-extra/src/extra/filters/each_while.rs b/crates/nu-cmd-extra/src/extra/filters/each_while.rs index 133ec43c3be6..773894f263b7 100644 --- a/crates/nu-cmd-extra/src/extra/filters/each_while.rs +++ b/crates/nu-cmd-extra/src/extra/filters/each_while.rs @@ -1,11 +1,5 @@ -use nu_engine::{get_eval_block_with_early_return, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, - Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block_with_early_return}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct EachWhile; diff --git a/crates/nu-cmd-extra/src/extra/filters/roll/mod.rs b/crates/nu-cmd-extra/src/extra/filters/roll/mod.rs index 8fb556755861..446200e0b80f 100644 --- a/crates/nu-cmd-extra/src/extra/filters/roll/mod.rs +++ b/crates/nu-cmd-extra/src/extra/filters/roll/mod.rs @@ -5,6 +5,7 @@ mod roll_right; mod roll_up; use nu_protocol::{ShellError, Value}; + pub use roll_::Roll; pub use roll_down::RollDown; pub use roll_left::RollLeft; diff --git a/crates/nu-cmd-extra/src/extra/filters/roll/roll_.rs b/crates/nu-cmd-extra/src/extra/filters/roll/roll_.rs index a4de6cc1c17f..76e167a5759b 100644 --- a/crates/nu-cmd-extra/src/extra/filters/roll/roll_.rs +++ b/crates/nu-cmd-extra/src/extra/filters/roll/roll_.rs @@ -1,7 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Roll; diff --git a/crates/nu-cmd-extra/src/extra/filters/roll/roll_down.rs b/crates/nu-cmd-extra/src/extra/filters/roll/roll_down.rs index d6a282b9c5e5..03c1a0c83f1a 100644 --- a/crates/nu-cmd-extra/src/extra/filters/roll/roll_down.rs +++ b/crates/nu-cmd-extra/src/extra/filters/roll/roll_down.rs @@ -1,12 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, - Type, Value, -}; - use super::{vertical_rotate_value, VerticalDirection}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct RollDown; diff --git a/crates/nu-cmd-extra/src/extra/filters/roll/roll_left.rs b/crates/nu-cmd-extra/src/extra/filters/roll/roll_left.rs index beb6193fd04d..1162400abe9a 100644 --- a/crates/nu-cmd-extra/src/extra/filters/roll/roll_left.rs +++ b/crates/nu-cmd-extra/src/extra/filters/roll/roll_left.rs @@ -1,12 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, - Type, Value, -}; - use super::{horizontal_rotate_value, HorizontalDirection}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct RollLeft; diff --git a/crates/nu-cmd-extra/src/extra/filters/roll/roll_right.rs b/crates/nu-cmd-extra/src/extra/filters/roll/roll_right.rs index be781519dc20..ae06d3529afa 100644 --- a/crates/nu-cmd-extra/src/extra/filters/roll/roll_right.rs +++ b/crates/nu-cmd-extra/src/extra/filters/roll/roll_right.rs @@ -1,12 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, - Type, Value, -}; - use super::{horizontal_rotate_value, HorizontalDirection}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct RollRight; diff --git a/crates/nu-cmd-extra/src/extra/filters/roll/roll_up.rs b/crates/nu-cmd-extra/src/extra/filters/roll/roll_up.rs index 6324fe9e889f..233e2f0899fc 100644 --- a/crates/nu-cmd-extra/src/extra/filters/roll/roll_up.rs +++ b/crates/nu-cmd-extra/src/extra/filters/roll/roll_up.rs @@ -1,12 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, - Type, Value, -}; - use super::{vertical_rotate_value, VerticalDirection}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct RollUp; diff --git a/crates/nu-cmd-extra/src/extra/filters/rotate.rs b/crates/nu-cmd-extra/src/extra/filters/rotate.rs index 575d799e97ec..f3988bcadb86 100644 --- a/crates/nu-cmd-extra/src/extra/filters/rotate.rs +++ b/crates/nu-cmd-extra/src/extra/filters/rotate.rs @@ -1,11 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::IntoPipelineData; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, Record, ShellError, Signature, SyntaxShape, Type, - Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Rotate; diff --git a/crates/nu-cmd-extra/src/extra/filters/update_cells.rs b/crates/nu-cmd-extra/src/extra/filters/update_cells.rs index c488f1d7aa90..cc1fc877c318 100644 --- a/crates/nu-cmd-extra/src/extra/filters/update_cells.rs +++ b/crates/nu-cmd-extra/src/extra/filters/update_cells.rs @@ -1,13 +1,6 @@ -use nu_engine::{get_eval_block, CallExt, EvalBlockFn}; -use nu_protocol::ast::{Block, Call}; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - PipelineIterator, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; -use std::collections::HashSet; -use std::sync::Arc; +use nu_engine::{command_prelude::*, get_eval_block, EvalBlockFn}; +use nu_protocol::{ast::Block, engine::Closure, PipelineIterator}; +use std::{collections::HashSet, sync::Arc}; #[derive(Clone)] pub struct UpdateCells; diff --git a/crates/nu-cmd-extra/src/extra/formats/from/url.rs b/crates/nu-cmd-extra/src/extra/formats/from/url.rs index fca1e0209c6c..1258bb2df6da 100644 --- a/crates/nu-cmd-extra/src/extra/formats/from/url.rs +++ b/crates/nu-cmd-extra/src/extra/formats/from/url.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct FromUrl; diff --git a/crates/nu-cmd-extra/src/extra/formats/to/html.rs b/crates/nu-cmd-extra/src/extra/formats/to/html.rs index 38e13803046d..08422bb02525 100644 --- a/crates/nu-cmd-extra/src/extra/formats/to/html.rs +++ b/crates/nu-cmd-extra/src/extra/formats/to/html.rs @@ -1,18 +1,11 @@ use fancy_regex::Regex; use nu_cmd_base::formats::to::delimited::merge_descriptors; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Config, DataSource, Example, IntoPipelineData, PipelineData, - PipelineMetadata, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::{Config, DataSource, PipelineMetadata}; use nu_utils::IgnoreCaseExt; use rust_embed::RustEmbed; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; -use std::error::Error; -use std::fmt::Write; +use std::{collections::HashMap, error::Error, fmt::Write}; #[derive(Serialize, Deserialize, Debug)] pub struct HtmlThemes { diff --git a/crates/nu-cmd-extra/src/extra/math/arccos.rs b/crates/nu-cmd-extra/src/extra/math/arccos.rs index 6477792f2b71..120fc4df984c 100644 --- a/crates/nu-cmd-extra/src/extra/math/arccos.rs +++ b/crates/nu-cmd-extra/src/extra/math/arccos.rs @@ -1,7 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/math/arccosh.rs b/crates/nu-cmd-extra/src/extra/math/arccosh.rs index f91f606d34d1..30e0d2cfb601 100644 --- a/crates/nu-cmd-extra/src/extra/math/arccosh.rs +++ b/crates/nu-cmd-extra/src/extra/math/arccosh.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/math/arcsin.rs b/crates/nu-cmd-extra/src/extra/math/arcsin.rs index 1cc675c95c6a..a68e0648efb1 100644 --- a/crates/nu-cmd-extra/src/extra/math/arcsin.rs +++ b/crates/nu-cmd-extra/src/extra/math/arcsin.rs @@ -1,7 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/math/arcsinh.rs b/crates/nu-cmd-extra/src/extra/math/arcsinh.rs index 80069f3d62ac..67addfdba215 100644 --- a/crates/nu-cmd-extra/src/extra/math/arcsinh.rs +++ b/crates/nu-cmd-extra/src/extra/math/arcsinh.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/math/arctan.rs b/crates/nu-cmd-extra/src/extra/math/arctan.rs index 4881989046f5..9c1420331246 100644 --- a/crates/nu-cmd-extra/src/extra/math/arctan.rs +++ b/crates/nu-cmd-extra/src/extra/math/arctan.rs @@ -1,7 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/math/arctanh.rs b/crates/nu-cmd-extra/src/extra/math/arctanh.rs index 69ad6b86a9b4..920e56eeb624 100644 --- a/crates/nu-cmd-extra/src/extra/math/arctanh.rs +++ b/crates/nu-cmd-extra/src/extra/math/arctanh.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/math/cos.rs b/crates/nu-cmd-extra/src/extra/math/cos.rs index 91868078ce11..633c131b8bdc 100644 --- a/crates/nu-cmd-extra/src/extra/math/cos.rs +++ b/crates/nu-cmd-extra/src/extra/math/cos.rs @@ -1,7 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/math/cosh.rs b/crates/nu-cmd-extra/src/extra/math/cosh.rs index b9eae5d27979..a772540b5ca7 100644 --- a/crates/nu-cmd-extra/src/extra/math/cosh.rs +++ b/crates/nu-cmd-extra/src/extra/math/cosh.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/math/exp.rs b/crates/nu-cmd-extra/src/extra/math/exp.rs index 1c19b0e000b2..b89d6f553f41 100644 --- a/crates/nu-cmd-extra/src/extra/math/exp.rs +++ b/crates/nu-cmd-extra/src/extra/math/exp.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/math/ln.rs b/crates/nu-cmd-extra/src/extra/math/ln.rs index 01fba009f431..dd9782b46733 100644 --- a/crates/nu-cmd-extra/src/extra/math/ln.rs +++ b/crates/nu-cmd-extra/src/extra/math/ln.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/math/sin.rs b/crates/nu-cmd-extra/src/extra/math/sin.rs index 4aaf3e1df67b..883007d1ed25 100644 --- a/crates/nu-cmd-extra/src/extra/math/sin.rs +++ b/crates/nu-cmd-extra/src/extra/math/sin.rs @@ -1,7 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/math/sinh.rs b/crates/nu-cmd-extra/src/extra/math/sinh.rs index ff92dc9a3088..c768dba739aa 100644 --- a/crates/nu-cmd-extra/src/extra/math/sinh.rs +++ b/crates/nu-cmd-extra/src/extra/math/sinh.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/math/tan.rs b/crates/nu-cmd-extra/src/extra/math/tan.rs index 16befaa11a48..e10807279dea 100644 --- a/crates/nu-cmd-extra/src/extra/math/tan.rs +++ b/crates/nu-cmd-extra/src/extra/math/tan.rs @@ -1,7 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/math/tanh.rs b/crates/nu-cmd-extra/src/extra/math/tanh.rs index fb0f3f7edef1..4d09f93cf4cc 100644 --- a/crates/nu-cmd-extra/src/extra/math/tanh.rs +++ b/crates/nu-cmd-extra/src/extra/math/tanh.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/mod.rs b/crates/nu-cmd-extra/src/extra/mod.rs index a17471ac8620..1877039a6f7c 100644 --- a/crates/nu-cmd-extra/src/extra/mod.rs +++ b/crates/nu-cmd-extra/src/extra/mod.rs @@ -6,33 +6,12 @@ mod math; mod platform; mod strings; -pub use bits::Bits; -pub use bits::BitsAnd; -pub use bits::BitsInto; -pub use bits::BitsNot; -pub use bits::BitsOr; -pub use bits::BitsRol; -pub use bits::BitsRor; -pub use bits::BitsShl; -pub use bits::BitsShr; -pub use bits::BitsXor; - -pub use math::MathCos; -pub use math::MathCosH; -pub use math::MathSin; -pub use math::MathSinH; -pub use math::MathTan; -pub use math::MathTanH; - -pub use math::MathExp; -pub use math::MathLn; - -pub use math::MathArcCos; -pub use math::MathArcCosH; -pub use math::MathArcSin; -pub use math::MathArcSinH; -pub use math::MathArcTan; -pub use math::MathArcTanH; +pub use bits::{ + Bits, BitsAnd, BitsInto, BitsNot, BitsOr, BitsRol, BitsRor, BitsShl, BitsShr, BitsXor, +}; +pub use math::{MathArcCos, MathArcCosH, MathArcSin, MathArcSinH, MathArcTan, MathArcTanH}; +pub use math::{MathCos, MathCosH, MathSin, MathSinH, MathTan, MathTanH}; +pub use math::{MathExp, MathLn}; use nu_protocol::engine::{EngineState, StateWorkingSet}; diff --git a/crates/nu-cmd-extra/src/extra/platform/ansi/gradient.rs b/crates/nu-cmd-extra/src/extra/platform/ansi/gradient.rs index 53d51b0d93f4..78ed09c2cb8d 100644 --- a/crates/nu-cmd-extra/src/extra/platform/ansi/gradient.rs +++ b/crates/nu-cmd-extra/src/extra/platform/ansi/gradient.rs @@ -1,9 +1,5 @@ use nu_ansi_term::{build_all_gradient_text, gradient::TargetGround, Gradient, Rgb}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, ast::CellPath, engine::Command, engine::EngineState, engine::Stack, Category, - Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/strings/encode_decode/decode_hex.rs b/crates/nu-cmd-extra/src/extra/strings/encode_decode/decode_hex.rs index 47cad462744f..9dd07b286eab 100644 --- a/crates/nu-cmd-extra/src/extra/strings/encode_decode/decode_hex.rs +++ b/crates/nu-cmd-extra/src/extra/strings/encode_decode/decode_hex.rs @@ -1,9 +1,5 @@ use super::hex::{operate, ActionType}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct DecodeHex; diff --git a/crates/nu-cmd-extra/src/extra/strings/encode_decode/encode_hex.rs b/crates/nu-cmd-extra/src/extra/strings/encode_decode/encode_hex.rs index 80681e30f40d..e68d556187e2 100644 --- a/crates/nu-cmd-extra/src/extra/strings/encode_decode/encode_hex.rs +++ b/crates/nu-cmd-extra/src/extra/strings/encode_decode/encode_hex.rs @@ -1,9 +1,5 @@ use super::hex::{operate, ActionType}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct EncodeHex; diff --git a/crates/nu-cmd-extra/src/extra/strings/encode_decode/hex.rs b/crates/nu-cmd-extra/src/extra/strings/encode_decode/hex.rs index a30596783a2f..7628d6e240af 100644 --- a/crates/nu-cmd-extra/src/extra/strings/encode_decode/hex.rs +++ b/crates/nu-cmd-extra/src/extra/strings/encode_decode/hex.rs @@ -1,8 +1,5 @@ use nu_cmd_base::input_handler::{operate as general_operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{EngineState, Stack}; -use nu_protocol::{PipelineData, ShellError, Span, Value}; +use nu_engine::command_prelude::*; enum HexDecodingError { InvalidLength(usize), diff --git a/crates/nu-cmd-extra/src/extra/strings/format/command.rs b/crates/nu-cmd-extra/src/extra/strings/format/command.rs index 4ec95ff37b07..5b63d29ae5dd 100644 --- a/crates/nu-cmd-extra/src/extra/strings/format/command.rs +++ b/crates/nu-cmd-extra/src/extra/strings/format/command.rs @@ -1,14 +1,6 @@ -use std::vec; - -use nu_engine::{get_eval_expression, CallExt}; +use nu_engine::{command_prelude::*, get_eval_expression}; use nu_parser::parse_expression; -use nu_protocol::ast::{Call, PathMember}; - -use nu_protocol::engine::{Command, EngineState, Stack, StateWorkingSet}; -use nu_protocol::{ - Category, Example, ListStream, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, - Value, -}; +use nu_protocol::{ast::PathMember, engine::StateWorkingSet, ListStream}; #[derive(Clone)] pub struct FormatPattern; diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/camel_case.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/camel_case.rs index c2abab0c2abe..e92126932ad2 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/camel_case.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/camel_case.rs @@ -1,11 +1,6 @@ -use heck::ToLowerCamelCase; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; - use super::operate; +use heck::ToLowerCamelCase; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/kebab_case.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/kebab_case.rs index a42cfc060e1c..e0869e77181a 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/kebab_case.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/kebab_case.rs @@ -1,11 +1,6 @@ -use heck::ToKebabCase; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; - use super::operate; +use heck::ToKebabCase; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/mod.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/mod.rs index 83617ab092a0..980a1b83fc99 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/mod.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/mod.rs @@ -14,12 +14,8 @@ pub use snake_case::SubCommand as StrSnakeCase; pub use str_::Str; pub use title_case::SubCommand as StrTitleCase; -use nu_engine::CallExt; - use nu_cmd_base::input_handler::{operate as general_operate, CmdArgument}; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{EngineState, Stack}; -use nu_protocol::{PipelineData, ShellError, Span, Value}; +use nu_engine::command_prelude::*; struct Arguments String + Send + Sync + 'static> { case_operation: &'static F, diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/pascal_case.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/pascal_case.rs index 9ad9fe1607a1..c99b8de22596 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/pascal_case.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/pascal_case.rs @@ -1,11 +1,6 @@ -use heck::ToUpperCamelCase; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; - use super::operate; +use heck::ToUpperCamelCase; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/screaming_snake_case.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/screaming_snake_case.rs index f6f1767f8ad3..498e0a8d96ab 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/screaming_snake_case.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/screaming_snake_case.rs @@ -1,11 +1,6 @@ -use heck::ToShoutySnakeCase; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; - use super::operate; +use heck::ToShoutySnakeCase; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/snake_case.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/snake_case.rs index 3fb50ca0f734..7af2f9bd43e5 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/snake_case.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/snake_case.rs @@ -1,11 +1,7 @@ +use super::operate; use heck::ToSnakeCase; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; -use super::operate; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/str_.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/str_.rs index a0731972a15c..cf4537f046be 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/str_.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/str_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Str; diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/title_case.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/title_case.rs index 29e9f9b89e9d..524ca76556e9 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/title_case.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/title_case.rs @@ -1,11 +1,6 @@ -use heck::ToTitleCase; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; - use super::operate; +use heck::ToTitleCase; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-cmd-lang/src/core_commands/alias.rs b/crates/nu-cmd-lang/src/core_commands/alias.rs index a32c0eba7825..f3603611e474 100644 --- a/crates/nu-cmd-lang/src/core_commands/alias.rs +++ b/crates/nu-cmd-lang/src/core_commands/alias.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Alias; diff --git a/crates/nu-cmd-lang/src/core_commands/break_.rs b/crates/nu-cmd-lang/src/core_commands/break_.rs index d257dbfd0d3e..4698f12c34a3 100644 --- a/crates/nu-cmd-lang/src/core_commands/break_.rs +++ b/crates/nu-cmd-lang/src/core_commands/break_.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Type}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Break; diff --git a/crates/nu-cmd-lang/src/core_commands/collect.rs b/crates/nu-cmd-lang/src/core_commands/collect.rs index be061373bc99..05726392d7aa 100644 --- a/crates/nu-cmd-lang/src/core_commands/collect.rs +++ b/crates/nu-cmd-lang/src/core_commands/collect.rs @@ -1,11 +1,5 @@ -use nu_engine::{get_eval_block, redirect_env, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, - Value, -}; +use nu_engine::{command_prelude::*, get_eval_block, redirect_env}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct Collect; diff --git a/crates/nu-cmd-lang/src/core_commands/const_.rs b/crates/nu-cmd-lang/src/core_commands/const_.rs index 03332f221b89..4076ae87c9d5 100644 --- a/crates/nu-cmd-lang/src/core_commands/const_.rs +++ b/crates/nu-cmd-lang/src/core_commands/const_.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Const; diff --git a/crates/nu-cmd-lang/src/core_commands/continue_.rs b/crates/nu-cmd-lang/src/core_commands/continue_.rs index b6feddf0d1a5..f65a983269d4 100644 --- a/crates/nu-cmd-lang/src/core_commands/continue_.rs +++ b/crates/nu-cmd-lang/src/core_commands/continue_.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Type}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Continue; diff --git a/crates/nu-cmd-lang/src/core_commands/def.rs b/crates/nu-cmd-lang/src/core_commands/def.rs index 1e42485f4344..922ba78abbce 100644 --- a/crates/nu-cmd-lang/src/core_commands/def.rs +++ b/crates/nu-cmd-lang/src/core_commands/def.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Def; diff --git a/crates/nu-cmd-lang/src/core_commands/describe.rs b/crates/nu-cmd-lang/src/core_commands/describe.rs index 9d2ca44483ea..842de60f6ac5 100644 --- a/crates/nu-cmd-lang/src/core_commands/describe.rs +++ b/crates/nu-cmd-lang/src/core_commands/describe.rs @@ -1,9 +1,7 @@ -use nu_engine::CallExt; +use nu_engine::command_prelude::*; use nu_protocol::{ - ast::Call, - engine::{Closure, Command, EngineState, Stack, StateWorkingSet}, - record, Category, Example, IntoPipelineData, PipelineData, PipelineMetadata, Record, - ShellError, Signature, Type, Value, + engine::{Closure, StateWorkingSet}, + PipelineMetadata, }; #[derive(Clone)] diff --git a/crates/nu-cmd-lang/src/core_commands/do_.rs b/crates/nu-cmd-lang/src/core_commands/do_.rs index 62cff41196a2..129460d5c4c3 100644 --- a/crates/nu-cmd-lang/src/core_commands/do_.rs +++ b/crates/nu-cmd-lang/src/core_commands/do_.rs @@ -1,14 +1,7 @@ +use nu_engine::{command_prelude::*, get_eval_block_with_early_return, redirect_env}; +use nu_protocol::{engine::Closure, IoStream, ListStream, RawStream}; use std::thread; -use nu_engine::{get_eval_block_with_early_return, redirect_env, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoSpanned, IoStream, ListStream, PipelineData, RawStream, ShellError, - Signature, Span, SyntaxShape, Type, Value, -}; - #[derive(Clone)] pub struct Do; diff --git a/crates/nu-cmd-lang/src/core_commands/echo.rs b/crates/nu-cmd-lang/src/core_commands/echo.rs index 6dc7769652e5..f28702ebc845 100644 --- a/crates/nu-cmd-lang/src/core_commands/echo.rs +++ b/crates/nu-cmd-lang/src/core_commands/echo.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Echo; diff --git a/crates/nu-cmd-lang/src/core_commands/error_make.rs b/crates/nu-cmd-lang/src/core_commands/error_make.rs index cb1ab9e91faa..987e083cbcce 100644 --- a/crates/nu-cmd-lang/src/core_commands/error_make.rs +++ b/crates/nu-cmd-lang/src/core_commands/error_make.rs @@ -1,10 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, LabeledError, PipelineData, Record, ShellError, Signature, Span, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::LabeledError; #[derive(Clone)] pub struct ErrorMake; diff --git a/crates/nu-cmd-lang/src/core_commands/export.rs b/crates/nu-cmd-lang/src/core_commands/export.rs index 7b8a9454132a..e5d3d4568370 100644 --- a/crates/nu-cmd-lang/src/core_commands/export.rs +++ b/crates/nu-cmd-lang/src/core_commands/export.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct ExportCommand; diff --git a/crates/nu-cmd-lang/src/core_commands/export_alias.rs b/crates/nu-cmd-lang/src/core_commands/export_alias.rs index c82894a08231..14caddcc7a28 100644 --- a/crates/nu-cmd-lang/src/core_commands/export_alias.rs +++ b/crates/nu-cmd-lang/src/core_commands/export_alias.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ExportAlias; diff --git a/crates/nu-cmd-lang/src/core_commands/export_const.rs b/crates/nu-cmd-lang/src/core_commands/export_const.rs index 1a3c419a3d41..988db50b2aad 100644 --- a/crates/nu-cmd-lang/src/core_commands/export_const.rs +++ b/crates/nu-cmd-lang/src/core_commands/export_const.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ExportConst; diff --git a/crates/nu-cmd-lang/src/core_commands/export_def.rs b/crates/nu-cmd-lang/src/core_commands/export_def.rs index 5d3f945cdef1..93c5932efb52 100644 --- a/crates/nu-cmd-lang/src/core_commands/export_def.rs +++ b/crates/nu-cmd-lang/src/core_commands/export_def.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ExportDef; diff --git a/crates/nu-cmd-lang/src/core_commands/export_extern.rs b/crates/nu-cmd-lang/src/core_commands/export_extern.rs index 70ed900890a7..9ca756cf9387 100644 --- a/crates/nu-cmd-lang/src/core_commands/export_extern.rs +++ b/crates/nu-cmd-lang/src/core_commands/export_extern.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ExportExtern; diff --git a/crates/nu-cmd-lang/src/core_commands/export_module.rs b/crates/nu-cmd-lang/src/core_commands/export_module.rs index dbe0c93516aa..fdbd143fb06e 100644 --- a/crates/nu-cmd-lang/src/core_commands/export_module.rs +++ b/crates/nu-cmd-lang/src/core_commands/export_module.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ExportModule; diff --git a/crates/nu-cmd-lang/src/core_commands/export_use.rs b/crates/nu-cmd-lang/src/core_commands/export_use.rs index c1904e819ae5..2e4fd3f3e933 100644 --- a/crates/nu-cmd-lang/src/core_commands/export_use.rs +++ b/crates/nu-cmd-lang/src/core_commands/export_use.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ExportUse; diff --git a/crates/nu-cmd-lang/src/core_commands/extern_.rs b/crates/nu-cmd-lang/src/core_commands/extern_.rs index d3f0ee24f0e9..71400dbb7c89 100644 --- a/crates/nu-cmd-lang/src/core_commands/extern_.rs +++ b/crates/nu-cmd-lang/src/core_commands/extern_.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Extern; diff --git a/crates/nu-cmd-lang/src/core_commands/for_.rs b/crates/nu-cmd-lang/src/core_commands/for_.rs index f99617cd47c3..8d1fa97cb024 100644 --- a/crates/nu-cmd-lang/src/core_commands/for_.rs +++ b/crates/nu-cmd-lang/src/core_commands/for_.rs @@ -1,11 +1,5 @@ -use nu_engine::{get_eval_block, get_eval_expression, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Block, Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, ListStream, PipelineData, ShellError, Signature, SyntaxShape, Type, - Value, -}; +use nu_engine::{command_prelude::*, get_eval_block, get_eval_expression}; +use nu_protocol::{engine::Block, ListStream}; #[derive(Clone)] pub struct For; diff --git a/crates/nu-cmd-lang/src/core_commands/hide.rs b/crates/nu-cmd-lang/src/core_commands/hide.rs index 192b3118e380..2cfafa6c0278 100644 --- a/crates/nu-cmd-lang/src/core_commands/hide.rs +++ b/crates/nu-cmd-lang/src/core_commands/hide.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Hide; diff --git a/crates/nu-cmd-lang/src/core_commands/hide_env.rs b/crates/nu-cmd-lang/src/core_commands/hide_env.rs index 4cbc50c877ff..73bff6e18ddb 100644 --- a/crates/nu-cmd-lang/src/core_commands/hide_env.rs +++ b/crates/nu-cmd-lang/src/core_commands/hide_env.rs @@ -1,10 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - did_you_mean, Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::did_you_mean; #[derive(Clone)] pub struct HideEnv; diff --git a/crates/nu-cmd-lang/src/core_commands/if_.rs b/crates/nu-cmd-lang/src/core_commands/if_.rs index 0d8c388451b0..4d53cdd61e0d 100644 --- a/crates/nu-cmd-lang/src/core_commands/if_.rs +++ b/crates/nu-cmd-lang/src/core_commands/if_.rs @@ -1,10 +1,9 @@ -use nu_engine::{get_eval_block, get_eval_expression, get_eval_expression_with_input, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Block, Command, EngineState, Stack, StateWorkingSet}; -use nu_protocol::eval_const::{eval_const_subexpression, eval_constant, eval_constant_with_input}; +use nu_engine::{ + command_prelude::*, get_eval_block, get_eval_expression, get_eval_expression_with_input, +}; use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, + engine::{Block, StateWorkingSet}, + eval_const::{eval_const_subexpression, eval_constant, eval_constant_with_input}, }; #[derive(Clone)] diff --git a/crates/nu-cmd-lang/src/core_commands/ignore.rs b/crates/nu-cmd-lang/src/core_commands/ignore.rs index b28ba1810cfd..9935286ee1ef 100644 --- a/crates/nu-cmd-lang/src/core_commands/ignore.rs +++ b/crates/nu-cmd-lang/src/core_commands/ignore.rs @@ -1,8 +1,5 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack, StateWorkingSet}; -use nu_protocol::{ - Category, Example, IoStream, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::{engine::StateWorkingSet, IoStream}; #[derive(Clone)] pub struct Ignore; diff --git a/crates/nu-cmd-lang/src/core_commands/lazy_make.rs b/crates/nu-cmd-lang/src/core_commands/lazy_make.rs index 22671b501dce..2f907658d2c7 100644 --- a/crates/nu-cmd-lang/src/core_commands/lazy_make.rs +++ b/crates/nu-cmd-lang/src/core_commands/lazy_make.rs @@ -1,14 +1,8 @@ -use std::collections::hash_map::Entry; -use std::collections::HashMap; -use std::sync::{Arc, Mutex}; - -use nu_engine::{eval_block, CallExt}; -use nu_protocol::ast::Call; -use nu_protocol::debugger::WithoutDebug; -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, LazyRecord, PipelineData, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, +use nu_engine::{command_prelude::*, eval_block}; +use nu_protocol::{debugger::WithoutDebug, engine::Closure, LazyRecord}; +use std::{ + collections::{hash_map::Entry, HashMap}, + sync::{Arc, Mutex}, }; #[derive(Clone)] diff --git a/crates/nu-cmd-lang/src/core_commands/let_.rs b/crates/nu-cmd-lang/src/core_commands/let_.rs index 639a6a43db36..949c883b4e82 100644 --- a/crates/nu-cmd-lang/src/core_commands/let_.rs +++ b/crates/nu-cmd-lang/src/core_commands/let_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_eval_block; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block}; #[derive(Clone)] pub struct Let; diff --git a/crates/nu-cmd-lang/src/core_commands/loop_.rs b/crates/nu-cmd-lang/src/core_commands/loop_.rs index 9718114fb5ad..d38a99640401 100644 --- a/crates/nu-cmd-lang/src/core_commands/loop_.rs +++ b/crates/nu-cmd-lang/src/core_commands/loop_.rs @@ -1,10 +1,5 @@ -use nu_engine::{get_eval_block, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Block, Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block}; +use nu_protocol::engine::Block; #[derive(Clone)] pub struct Loop; diff --git a/crates/nu-cmd-lang/src/core_commands/match_.rs b/crates/nu-cmd-lang/src/core_commands/match_.rs index 79e82faa34db..fc4af9dc51e6 100644 --- a/crates/nu-cmd-lang/src/core_commands/match_.rs +++ b/crates/nu-cmd-lang/src/core_commands/match_.rs @@ -1,9 +1,9 @@ -use nu_engine::{get_eval_block, get_eval_expression, get_eval_expression_with_input, CallExt}; -use nu_protocol::ast::{Call, Expr, Expression}; - -use nu_protocol::engine::{Command, EngineState, Matcher, Stack}; +use nu_engine::{ + command_prelude::*, get_eval_block, get_eval_expression, get_eval_expression_with_input, +}; use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, + ast::{Expr, Expression}, + engine::Matcher, }; #[derive(Clone)] diff --git a/crates/nu-cmd-lang/src/core_commands/module.rs b/crates/nu-cmd-lang/src/core_commands/module.rs index b0ac516d1103..45641649ff98 100644 --- a/crates/nu-cmd-lang/src/core_commands/module.rs +++ b/crates/nu-cmd-lang/src/core_commands/module.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Module; diff --git a/crates/nu-cmd-lang/src/core_commands/mut_.rs b/crates/nu-cmd-lang/src/core_commands/mut_.rs index b05a03ebe701..481f16a7c561 100644 --- a/crates/nu-cmd-lang/src/core_commands/mut_.rs +++ b/crates/nu-cmd-lang/src/core_commands/mut_.rs @@ -1,10 +1,4 @@ -use nu_engine::get_eval_block; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block}; #[derive(Clone)] pub struct Mut; diff --git a/crates/nu-cmd-lang/src/core_commands/overlay/command.rs b/crates/nu-cmd-lang/src/core_commands/overlay/command.rs index d05669629082..db502c093243 100644 --- a/crates/nu-cmd-lang/src/core_commands/overlay/command.rs +++ b/crates/nu-cmd-lang/src/core_commands/overlay/command.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Overlay; diff --git a/crates/nu-cmd-lang/src/core_commands/overlay/hide.rs b/crates/nu-cmd-lang/src/core_commands/overlay/hide.rs index 30a7aa4397a6..c1b4a653bcf6 100644 --- a/crates/nu-cmd-lang/src/core_commands/overlay/hide.rs +++ b/crates/nu-cmd-lang/src/core_commands/overlay/hide.rs @@ -1,9 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct OverlayHide; diff --git a/crates/nu-cmd-lang/src/core_commands/overlay/list.rs b/crates/nu-cmd-lang/src/core_commands/overlay/list.rs index 097cbc5a6a3d..776753cba827 100644 --- a/crates/nu-cmd-lang/src/core_commands/overlay/list.rs +++ b/crates/nu-cmd-lang/src/core_commands/overlay/list.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct OverlayList; diff --git a/crates/nu-cmd-lang/src/core_commands/overlay/new.rs b/crates/nu-cmd-lang/src/core_commands/overlay/new.rs index 0844574496d1..8f9a0e53ea83 100644 --- a/crates/nu-cmd-lang/src/core_commands/overlay/new.rs +++ b/crates/nu-cmd-lang/src/core_commands/overlay/new.rs @@ -1,9 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct OverlayNew; diff --git a/crates/nu-cmd-lang/src/core_commands/overlay/use_.rs b/crates/nu-cmd-lang/src/core_commands/overlay/use_.rs index f3d5610de1c7..13c3f711ad97 100644 --- a/crates/nu-cmd-lang/src/core_commands/overlay/use_.rs +++ b/crates/nu-cmd-lang/src/core_commands/overlay/use_.rs @@ -1,10 +1,8 @@ -use nu_engine::{find_in_dirs_env, get_dirs_var_from_call, get_eval_block, redirect_env, CallExt}; -use nu_parser::trim_quotes_str; -use nu_protocol::ast::{Call, Expr}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, +use nu_engine::{ + command_prelude::*, find_in_dirs_env, get_dirs_var_from_call, get_eval_block, redirect_env, }; +use nu_parser::trim_quotes_str; +use nu_protocol::ast::Expr; use std::path::Path; diff --git a/crates/nu-cmd-lang/src/core_commands/plugin.rs b/crates/nu-cmd-lang/src/core_commands/plugin.rs index 80745908b94b..7ac6bf09eb7e 100644 --- a/crates/nu-cmd-lang/src/core_commands/plugin.rs +++ b/crates/nu-cmd-lang/src/core_commands/plugin.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct PluginCommand; diff --git a/crates/nu-cmd-lang/src/core_commands/plugin_list.rs b/crates/nu-cmd-lang/src/core_commands/plugin_list.rs index 50d97de6cbb6..80f7e56a00f0 100644 --- a/crates/nu-cmd-lang/src/core_commands/plugin_list.rs +++ b/crates/nu-cmd-lang/src/core_commands/plugin_list.rs @@ -1,10 +1,5 @@ use itertools::Itertools; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, - Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct PluginList; diff --git a/crates/nu-cmd-lang/src/core_commands/plugin_stop.rs b/crates/nu-cmd-lang/src/core_commands/plugin_stop.rs index 46d5bcb3e857..7171fbf339ce 100644 --- a/crates/nu-cmd-lang/src/core_commands/plugin_stop.rs +++ b/crates/nu-cmd-lang/src/core_commands/plugin_stop.rs @@ -1,9 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct PluginStop; diff --git a/crates/nu-cmd-lang/src/core_commands/register.rs b/crates/nu-cmd-lang/src/core_commands/register.rs index 7e25b48336bd..09ccaf866f99 100644 --- a/crates/nu-cmd-lang/src/core_commands/register.rs +++ b/crates/nu-cmd-lang/src/core_commands/register.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Register; diff --git a/crates/nu-cmd-lang/src/core_commands/return_.rs b/crates/nu-cmd-lang/src/core_commands/return_.rs index 421563ef467d..48c04f80f273 100644 --- a/crates/nu-cmd-lang/src/core_commands/return_.rs +++ b/crates/nu-cmd-lang/src/core_commands/return_.rs @@ -1,9 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Return; diff --git a/crates/nu-cmd-lang/src/core_commands/scope/aliases.rs b/crates/nu-cmd-lang/src/core_commands/scope/aliases.rs index e2ce361893b5..780d8d5a1331 100644 --- a/crates/nu-cmd-lang/src/core_commands/scope/aliases.rs +++ b/crates/nu-cmd-lang/src/core_commands/scope/aliases.rs @@ -1,9 +1,4 @@ -use nu_engine::scope::ScopeData; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Type, -}; +use nu_engine::{command_prelude::*, scope::ScopeData}; #[derive(Clone)] pub struct ScopeAliases; diff --git a/crates/nu-cmd-lang/src/core_commands/scope/command.rs b/crates/nu-cmd-lang/src/core_commands/scope/command.rs index 930691f4ac07..da507f3159ff 100644 --- a/crates/nu-cmd-lang/src/core_commands/scope/command.rs +++ b/crates/nu-cmd-lang/src/core_commands/scope/command.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Scope; diff --git a/crates/nu-cmd-lang/src/core_commands/scope/commands.rs b/crates/nu-cmd-lang/src/core_commands/scope/commands.rs index 3909e4d98552..4a2a0225a5a0 100644 --- a/crates/nu-cmd-lang/src/core_commands/scope/commands.rs +++ b/crates/nu-cmd-lang/src/core_commands/scope/commands.rs @@ -1,9 +1,4 @@ -use nu_engine::scope::ScopeData; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Type, -}; +use nu_engine::{command_prelude::*, scope::ScopeData}; #[derive(Clone)] pub struct ScopeCommands; diff --git a/crates/nu-cmd-lang/src/core_commands/scope/engine_stats.rs b/crates/nu-cmd-lang/src/core_commands/scope/engine_stats.rs index 4ea5c326132f..649f622cd671 100644 --- a/crates/nu-cmd-lang/src/core_commands/scope/engine_stats.rs +++ b/crates/nu-cmd-lang/src/core_commands/scope/engine_stats.rs @@ -1,7 +1,4 @@ -use nu_engine::scope::ScopeData; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type}; +use nu_engine::{command_prelude::*, scope::ScopeData}; #[derive(Clone)] pub struct ScopeEngineStats; diff --git a/crates/nu-cmd-lang/src/core_commands/scope/externs.rs b/crates/nu-cmd-lang/src/core_commands/scope/externs.rs index 952c7b1bcc1f..30cdc53f2664 100644 --- a/crates/nu-cmd-lang/src/core_commands/scope/externs.rs +++ b/crates/nu-cmd-lang/src/core_commands/scope/externs.rs @@ -1,9 +1,4 @@ -use nu_engine::scope::ScopeData; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Type, -}; +use nu_engine::{command_prelude::*, scope::ScopeData}; #[derive(Clone)] pub struct ScopeExterns; diff --git a/crates/nu-cmd-lang/src/core_commands/scope/modules.rs b/crates/nu-cmd-lang/src/core_commands/scope/modules.rs index 82d7f8216cf9..6031121847b7 100644 --- a/crates/nu-cmd-lang/src/core_commands/scope/modules.rs +++ b/crates/nu-cmd-lang/src/core_commands/scope/modules.rs @@ -1,9 +1,4 @@ -use nu_engine::scope::ScopeData; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Type, -}; +use nu_engine::{command_prelude::*, scope::ScopeData}; #[derive(Clone)] pub struct ScopeModules; diff --git a/crates/nu-cmd-lang/src/core_commands/scope/variables.rs b/crates/nu-cmd-lang/src/core_commands/scope/variables.rs index 9ec8176e0efd..7f44289fb41b 100644 --- a/crates/nu-cmd-lang/src/core_commands/scope/variables.rs +++ b/crates/nu-cmd-lang/src/core_commands/scope/variables.rs @@ -1,9 +1,4 @@ -use nu_engine::scope::ScopeData; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Type, -}; +use nu_engine::{command_prelude::*, scope::ScopeData}; #[derive(Clone)] pub struct ScopeVariables; diff --git a/crates/nu-cmd-lang/src/core_commands/try_.rs b/crates/nu-cmd-lang/src/core_commands/try_.rs index 449ab6f72d7d..5ee18f722aa1 100644 --- a/crates/nu-cmd-lang/src/core_commands/try_.rs +++ b/crates/nu-cmd-lang/src/core_commands/try_.rs @@ -1,11 +1,5 @@ -use nu_engine::{get_eval_block, CallExt, EvalBlockFn}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Block, Closure, Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, - SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block, EvalBlockFn}; +use nu_protocol::engine::{Block, Closure}; #[derive(Clone)] pub struct Try; diff --git a/crates/nu-cmd-lang/src/core_commands/use_.rs b/crates/nu-cmd-lang/src/core_commands/use_.rs index bd47991c21a7..32978d7e626e 100644 --- a/crates/nu-cmd-lang/src/core_commands/use_.rs +++ b/crates/nu-cmd-lang/src/core_commands/use_.rs @@ -1,10 +1,7 @@ -use nu_engine::{find_in_dirs_env, get_dirs_var_from_call, get_eval_block, redirect_env}; -use nu_protocol::ast::{Call, Expr, Expression}; - -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, +use nu_engine::{ + command_prelude::*, find_in_dirs_env, get_dirs_var_from_call, get_eval_block, redirect_env, }; +use nu_protocol::ast::{Expr, Expression}; #[derive(Clone)] pub struct Use; diff --git a/crates/nu-cmd-lang/src/core_commands/version.rs b/crates/nu-cmd-lang/src/core_commands/version.rs index 0b64f879a0ce..a8d6c4f21f99 100644 --- a/crates/nu-cmd-lang/src/core_commands/version.rs +++ b/crates/nu-cmd-lang/src/core_commands/version.rs @@ -1,8 +1,5 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack, StateWorkingSet}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, Record, ShellError, Signature, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::engine::StateWorkingSet; use shadow_rs::shadow; shadow!(build); diff --git a/crates/nu-cmd-lang/src/core_commands/while_.rs b/crates/nu-cmd-lang/src/core_commands/while_.rs index d98c69d01586..fee61f0f0004 100644 --- a/crates/nu-cmd-lang/src/core_commands/while_.rs +++ b/crates/nu-cmd-lang/src/core_commands/while_.rs @@ -1,10 +1,5 @@ -use nu_engine::{get_eval_block, get_eval_expression, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Block, Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block, get_eval_expression}; +use nu_protocol::engine::Block; #[derive(Clone)] pub struct While; diff --git a/crates/nu-cmd-lang/src/default_context.rs b/crates/nu-cmd-lang/src/default_context.rs index 63665230afeb..f08717d4bdbf 100644 --- a/crates/nu-cmd-lang/src/default_context.rs +++ b/crates/nu-cmd-lang/src/default_context.rs @@ -1,6 +1,5 @@ -use nu_protocol::engine::{EngineState, StateWorkingSet}; - use crate::*; +use nu_protocol::engine::{EngineState, StateWorkingSet}; pub fn create_default_context() -> EngineState { let mut engine_state = EngineState::new(); diff --git a/crates/nu-cmd-lang/src/example_support.rs b/crates/nu-cmd-lang/src/example_support.rs index 8e848c20def3..1efe69bc9868 100644 --- a/crates/nu-cmd-lang/src/example_support.rs +++ b/crates/nu-cmd-lang/src/example_support.rs @@ -1,12 +1,11 @@ use itertools::Itertools; -use nu_protocol::debugger::WithoutDebug; +use nu_engine::command_prelude::*; use nu_protocol::{ ast::{Block, RangeInclusion}, - engine::{EngineState, Stack, StateDelta, StateWorkingSet}, - Example, PipelineData, Signature, Span, Type, Value, + debugger::WithoutDebug, + engine::{StateDelta, StateWorkingSet}, }; -use std::collections::HashSet; -use std::sync::Arc; +use std::{collections::HashSet, sync::Arc}; pub fn check_example_input_and_output_types_match_command_signature( example: &Example, diff --git a/crates/nu-color-config/src/style_computer.rs b/crates/nu-color-config/src/style_computer.rs index 4afd63e917b7..1261bd9d0697 100644 --- a/crates/nu-color-config/src/style_computer.rs +++ b/crates/nu-color-config/src/style_computer.rs @@ -1,16 +1,16 @@ -use crate::text_style::Alignment; -use crate::{color_record_to_nustyle, lookup_ansi_color_style, TextStyle}; +use crate::{color_record_to_nustyle, lookup_ansi_color_style, text_style::Alignment, TextStyle}; use nu_ansi_term::{Color, Style}; use nu_engine::{env::get_config, eval_block}; use nu_protocol::{ cli_error::CliError, + debugger::WithoutDebug, engine::{EngineState, Stack, StateWorkingSet}, IntoPipelineData, Value, }; -use std::collections::HashMap; - -use nu_protocol::debugger::WithoutDebug; -use std::fmt::{Debug, Formatter, Result}; +use std::{ + collections::HashMap, + fmt::{Debug, Formatter, Result}, +}; // ComputableStyle represents the valid user style types: a single color value, or a closure which // takes an input value and produces a color value. The latter represents a value which diff --git a/crates/nu-command/src/bytes/add.rs b/crates/nu-command/src/bytes/add.rs index 30c4231ace9a..dca8707b49e6 100644 --- a/crates/nu-command/src/bytes/add.rs +++ b/crates/nu-command/src/bytes/add.rs @@ -1,10 +1,5 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; struct Arguments { added_data: Vec, diff --git a/crates/nu-command/src/bytes/at.rs b/crates/nu-command/src/bytes/at.rs index 6e510c0d2f8b..6823b014034d 100644 --- a/crates/nu-command/src/bytes/at.rs +++ b/crates/nu-command/src/bytes/at.rs @@ -1,12 +1,9 @@ -use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_cmd_base::util; -use nu_engine::CallExt; -use nu_protocol::record; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, Range, ShellError, Signature, Span, SyntaxShape, Type, Value, +use nu_cmd_base::{ + input_handler::{operate, CmdArgument}, + util, }; +use nu_engine::command_prelude::*; +use nu_protocol::Range; #[derive(Clone)] pub struct BytesAt; diff --git a/crates/nu-command/src/bytes/build_.rs b/crates/nu-command/src/bytes/build_.rs index 9fecdc450535..29c231b10829 100644 --- a/crates/nu-command/src/bytes/build_.rs +++ b/crates/nu-command/src/bytes/build_.rs @@ -1,11 +1,4 @@ -use nu_engine::get_eval_expression; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_expression}; #[derive(Clone)] pub struct BytesBuild; diff --git a/crates/nu-command/src/bytes/bytes_.rs b/crates/nu-command/src/bytes/bytes_.rs index 2b64bca9c7fe..f262e6a82e9d 100644 --- a/crates/nu-command/src/bytes/bytes_.rs +++ b/crates/nu-command/src/bytes/bytes_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Bytes; diff --git a/crates/nu-command/src/bytes/collect.rs b/crates/nu-command/src/bytes/collect.rs index f819284ddd56..9cd34496e492 100644 --- a/crates/nu-command/src/bytes/collect.rs +++ b/crates/nu-command/src/bytes/collect.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone, Copy)] pub struct BytesCollect; diff --git a/crates/nu-command/src/bytes/ends_with.rs b/crates/nu-command/src/bytes/ends_with.rs index aea13cb36f82..5f421d5216df 100644 --- a/crates/nu-command/src/bytes/ends_with.rs +++ b/crates/nu-command/src/bytes/ends_with.rs @@ -1,10 +1,5 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; struct Arguments { pattern: Vec, diff --git a/crates/nu-command/src/bytes/index_of.rs b/crates/nu-command/src/bytes/index_of.rs index 2eb169acd7b1..332a541add26 100644 --- a/crates/nu-command/src/bytes/index_of.rs +++ b/crates/nu-command/src/bytes/index_of.rs @@ -1,10 +1,5 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; struct Arguments { pattern: Vec, diff --git a/crates/nu-command/src/bytes/length.rs b/crates/nu-command/src/bytes/length.rs index 49f552d40431..7af3876113f9 100644 --- a/crates/nu-command/src/bytes/length.rs +++ b/crates/nu-command/src/bytes/length.rs @@ -1,10 +1,5 @@ use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct BytesLen; diff --git a/crates/nu-command/src/bytes/remove.rs b/crates/nu-command/src/bytes/remove.rs index 1404a69ddb5c..6a95c050f4e7 100644 --- a/crates/nu-command/src/bytes/remove.rs +++ b/crates/nu-command/src/bytes/remove.rs @@ -1,11 +1,5 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; struct Arguments { pattern: Vec, diff --git a/crates/nu-command/src/bytes/replace.rs b/crates/nu-command/src/bytes/replace.rs index e90b138bab8b..5b7e75777bcd 100644 --- a/crates/nu-command/src/bytes/replace.rs +++ b/crates/nu-command/src/bytes/replace.rs @@ -1,11 +1,5 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; struct Arguments { find: Vec, diff --git a/crates/nu-command/src/bytes/reverse.rs b/crates/nu-command/src/bytes/reverse.rs index eed6a33df7ba..f1dfb22b416a 100644 --- a/crates/nu-command/src/bytes/reverse.rs +++ b/crates/nu-command/src/bytes/reverse.rs @@ -1,13 +1,7 @@ use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] - pub struct BytesReverse; impl Command for BytesReverse { diff --git a/crates/nu-command/src/bytes/starts_with.rs b/crates/nu-command/src/bytes/starts_with.rs index 022c795cd441..07b1b42547dd 100644 --- a/crates/nu-command/src/bytes/starts_with.rs +++ b/crates/nu-command/src/bytes/starts_with.rs @@ -1,11 +1,5 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::IntoPipelineData; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; struct Arguments { pattern: Vec, diff --git a/crates/nu-command/src/charting/histogram.rs b/crates/nu-command/src/charting/histogram.rs index b39e75887ccc..bd94af2ed3ae 100755 --- a/crates/nu-command/src/charting/histogram.rs +++ b/crates/nu-command/src/charting/histogram.rs @@ -1,12 +1,7 @@ use super::hashable_value::HashableValue; use itertools::Itertools; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use std::collections::HashMap; #[derive(Clone)] diff --git a/crates/nu-command/src/conversions/fill.rs b/crates/nu-command/src/conversions/fill.rs index 1d9c8f0d87e0..76ec1e81e5a5 100644 --- a/crates/nu-command/src/conversions/fill.rs +++ b/crates/nu-command/src/conversions/fill.rs @@ -1,10 +1,6 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use print_positions::print_positions; #[derive(Clone)] diff --git a/crates/nu-command/src/conversions/into/binary.rs b/crates/nu-command/src/conversions/into/binary.rs index 2c349b943d4b..36f6316a6dea 100644 --- a/crates/nu-command/src/conversions/into/binary.rs +++ b/crates/nu-command/src/conversions/into/binary.rs @@ -1,11 +1,5 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; pub struct Arguments { cell_paths: Option>, diff --git a/crates/nu-command/src/conversions/into/bool.rs b/crates/nu-command/src/conversions/into/bool.rs index 8a94b095f152..e8ac87ed7911 100644 --- a/crates/nu-command/src/conversions/into/bool.rs +++ b/crates/nu-command/src/conversions/into/bool.rs @@ -1,10 +1,5 @@ use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/conversions/into/cell_path.rs b/crates/nu-command/src/conversions/into/cell_path.rs index 5f59b72b8f5b..1b42e847a60a 100644 --- a/crates/nu-command/src/conversions/into/cell_path.rs +++ b/crates/nu-command/src/conversions/into/cell_path.rs @@ -1,9 +1,5 @@ -use nu_protocol::{ - ast::{Call, CellPath, PathMember}, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, Record, ShellError, Signature, Span, Type, - Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::ast::{CellPath, PathMember}; #[derive(Clone)] pub struct IntoCellPath; diff --git a/crates/nu-command/src/conversions/into/command.rs b/crates/nu-command/src/conversions/into/command.rs index 1b59793edb33..37bbbff02e18 100644 --- a/crates/nu-command/src/conversions/into/command.rs +++ b/crates/nu-command/src/conversions/into/command.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Into; diff --git a/crates/nu-command/src/conversions/into/datetime.rs b/crates/nu-command/src/conversions/into/datetime.rs index 2228ed4de6f7..ff2dca88a5de 100644 --- a/crates/nu-command/src/conversions/into/datetime.rs +++ b/crates/nu-command/src/conversions/into/datetime.rs @@ -1,15 +1,8 @@ use crate::{generate_strftime_list, parse_date_from_string}; -use chrono::NaiveTime; -use chrono::{DateTime, FixedOffset, Local, TimeZone, Utc}; +use chrono::{DateTime, FixedOffset, Local, NaiveTime, TimeZone, Utc}; use human_date_parser::{from_human_time, ParseResult}; use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; struct Arguments { zone_options: Option>, diff --git a/crates/nu-command/src/conversions/into/duration.rs b/crates/nu-command/src/conversions/into/duration.rs index 4dcf95d94f74..7ff1f9c5c168 100644 --- a/crates/nu-command/src/conversions/into/duration.rs +++ b/crates/nu-command/src/conversions/into/duration.rs @@ -1,10 +1,8 @@ -use nu_engine::CallExt; +use nu_engine::command_prelude::*; use nu_parser::{parse_unit_value, DURATION_UNIT_GROUPS}; use nu_protocol::{ - ast::{Call, CellPath, Expr}, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Unit, - Value, + ast::{CellPath, Expr}, + Unit, }; const NS_PER_SEC: i64 = 1_000_000_000; diff --git a/crates/nu-command/src/conversions/into/filesize.rs b/crates/nu-command/src/conversions/into/filesize.rs index 967d933b436f..c97209cd8c50 100644 --- a/crates/nu-command/src/conversions/into/filesize.rs +++ b/crates/nu-command/src/conversions/into/filesize.rs @@ -1,10 +1,6 @@ use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use nu_utils::get_system_locale; #[derive(Clone)] diff --git a/crates/nu-command/src/conversions/into/float.rs b/crates/nu-command/src/conversions/into/float.rs index 2a4a53e30417..7b877ead0837 100644 --- a/crates/nu-command/src/conversions/into/float.rs +++ b/crates/nu-command/src/conversions/into/float.rs @@ -1,10 +1,5 @@ use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/conversions/into/glob.rs b/crates/nu-command/src/conversions/into/glob.rs index d009d324c8b1..80cc1587cf3f 100644 --- a/crates/nu-command/src/conversions/into/glob.rs +++ b/crates/nu-command/src/conversions/into/glob.rs @@ -1,11 +1,5 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; struct Arguments { cell_paths: Option>, diff --git a/crates/nu-command/src/conversions/into/int.rs b/crates/nu-command/src/conversions/into/int.rs index 30b08d0bc19a..955ccf3c65cb 100644 --- a/crates/nu-command/src/conversions/into/int.rs +++ b/crates/nu-command/src/conversions/into/int.rs @@ -1,11 +1,7 @@ use chrono::{FixedOffset, TimeZone}; use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use nu_utils::get_system_locale; struct Arguments { diff --git a/crates/nu-command/src/conversions/into/record.rs b/crates/nu-command/src/conversions/into/record.rs index 1405ceb3a7cc..e0d351665496 100644 --- a/crates/nu-command/src/conversions/into/record.rs +++ b/crates/nu-command/src/conversions/into/record.rs @@ -1,10 +1,6 @@ use chrono::{DateTime, Datelike, FixedOffset, Timelike}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - format_duration_as_timeperiod, record, Category, Example, IntoPipelineData, PipelineData, - Record, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::format_duration_as_timeperiod; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/conversions/into/string.rs b/crates/nu-command/src/conversions/into/string.rs index 2c1b232eea39..7ba68dc14335 100644 --- a/crates/nu-command/src/conversions/into/string.rs +++ b/crates/nu-command/src/conversions/into/string.rs @@ -1,11 +1,6 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - into_code, Category, Config, Example, IntoPipelineData, PipelineData, ShellError, Signature, - Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::{into_code, Config}; use nu_utils::get_system_locale; use num_format::ToFormattedString; diff --git a/crates/nu-command/src/conversions/into/value.rs b/crates/nu-command/src/conversions/into/value.rs index 936b70ea1570..9c3cda77a25e 100644 --- a/crates/nu-command/src/conversions/into/value.rs +++ b/crates/nu-command/src/conversions/into/value.rs @@ -1,11 +1,6 @@ use crate::parse_date_from_string; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoInterruptiblePipelineData, PipelineData, PipelineIterator, ShellError, - Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::PipelineIterator; use once_cell::sync::Lazy; use regex::{Regex, RegexBuilder}; use std::collections::HashSet; diff --git a/crates/nu-command/src/database/commands/into_sqlite.rs b/crates/nu-command/src/database/commands/into_sqlite.rs index af093927c5c4..9d9a5ea8c341 100644 --- a/crates/nu-command/src/database/commands/into_sqlite.rs +++ b/crates/nu-command/src/database/commands/into_sqlite.rs @@ -1,15 +1,13 @@ use crate::database::values::sqlite::{open_sqlite_db, values_to_sql}; - -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, Record, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, +use nu_engine::command_prelude::*; + +use std::{ + path::Path, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, }; -use std::path::Path; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; pub const DEFAULT_TABLE_NAME: &str = "main"; diff --git a/crates/nu-command/src/database/commands/query_db.rs b/crates/nu-command/src/database/commands/query_db.rs index 99e5d0e4a8bc..6a132e269899 100644 --- a/crates/nu-command/src/database/commands/query_db.rs +++ b/crates/nu-command/src/database/commands/query_db.rs @@ -1,14 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, -}; - -use crate::database::values::sqlite::nu_value_to_params; - -use super::super::SQLiteDatabase; +use crate::database::{values::sqlite::nu_value_to_params, SQLiteDatabase}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct QueryDb; diff --git a/crates/nu-command/src/database/commands/schema.rs b/crates/nu-command/src/database/commands/schema.rs index 8a2c97f8507f..ab7b36dab207 100644 --- a/crates/nu-command/src/database/commands/schema.rs +++ b/crates/nu-command/src/database/commands/schema.rs @@ -1,11 +1,8 @@ use super::super::SQLiteDatabase; use crate::database::values::definitions::{db_row::DbRow, db_table::DbTable}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, Record, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; use rusqlite::Connection; + #[derive(Clone)] pub struct SchemaDb; diff --git a/crates/nu-command/src/date/date_.rs b/crates/nu-command/src/date/date_.rs index 81ab887d9d37..158940cc2e3f 100644 --- a/crates/nu-command/src/date/date_.rs +++ b/crates/nu-command/src/date/date_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Date; diff --git a/crates/nu-command/src/date/humanize.rs b/crates/nu-command/src/date/humanize.rs index b46f516e3c30..b47288f6360e 100644 --- a/crates/nu-command/src/date/humanize.rs +++ b/crates/nu-command/src/date/humanize.rs @@ -1,9 +1,8 @@ use crate::date::utils::parse_date_from_string; use chrono::{DateTime, FixedOffset, Local}; use chrono_humanize::HumanTime; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; + #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/date/list_timezone.rs b/crates/nu-command/src/date/list_timezone.rs index e0399564a339..0bd37a4d4113 100644 --- a/crates/nu-command/src/date/list_timezone.rs +++ b/crates/nu-command/src/date/list_timezone.rs @@ -1,10 +1,5 @@ use chrono_tz::TZ_VARIANTS; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, - Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/date/now.rs b/crates/nu-command/src/date/now.rs index ddd5c71aa153..adc75e376000 100644 --- a/crates/nu-command/src/date/now.rs +++ b/crates/nu-command/src/date/now.rs @@ -1,9 +1,6 @@ use chrono::Local; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::command_prelude::*; + #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/date/to_record.rs b/crates/nu-command/src/date/to_record.rs index 589bb2d62164..9d42e42d902a 100644 --- a/crates/nu-command/src/date/to_record.rs +++ b/crates/nu-command/src/date/to_record.rs @@ -1,11 +1,6 @@ use crate::date::utils::parse_date_from_string; use chrono::{DateTime, Datelike, FixedOffset, Local, Timelike}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, ShellError::DatetimeParseError, - ShellError::PipelineEmpty, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; @@ -43,7 +38,7 @@ impl Command for SubCommand { let head = call.head; // This doesn't match explicit nulls if matches!(input, PipelineData::Empty) { - return Err(PipelineEmpty { dst_span: head }); + return Err(ShellError::PipelineEmpty { dst_span: head }); } input.map(move |value| helper(value, head), engine_state.ctrlc.clone()) } @@ -117,7 +112,7 @@ fn helper(val: Value, head: Span) -> Value { } Value::Date { val, .. } => parse_date_into_table(val, head), _ => Value::error( - DatetimeParseError { + ShellError::DatetimeParseError { msg: val.to_debug_string(), span: head, }, diff --git a/crates/nu-command/src/date/to_table.rs b/crates/nu-command/src/date/to_table.rs index 8688d298100f..0c0690e09b4d 100644 --- a/crates/nu-command/src/date/to_table.rs +++ b/crates/nu-command/src/date/to_table.rs @@ -1,11 +1,6 @@ use crate::date::utils::parse_date_from_string; use chrono::{DateTime, Datelike, FixedOffset, Local, Timelike}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, ShellError::DatetimeParseError, - ShellError::PipelineEmpty, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; @@ -43,7 +38,7 @@ impl Command for SubCommand { let head = call.head; // This doesn't match explicit nulls if matches!(input, PipelineData::Empty) { - return Err(PipelineEmpty { dst_span: head }); + return Err(ShellError::PipelineEmpty { dst_span: head }); } input.map(move |value| helper(value, head), engine_state.ctrlc.clone()) } @@ -116,7 +111,7 @@ fn helper(val: Value, head: Span) -> Value { } Value::Date { val, .. } => parse_date_into_table(val, head), _ => Value::error( - DatetimeParseError { + ShellError::DatetimeParseError { msg: val.to_debug_string(), span: head, }, diff --git a/crates/nu-command/src/date/to_timezone.rs b/crates/nu-command/src/date/to_timezone.rs index 035bd4f70230..2b555c02bf35 100644 --- a/crates/nu-command/src/date/to_timezone.rs +++ b/crates/nu-command/src/date/to_timezone.rs @@ -1,14 +1,7 @@ use super::parser::datetime_in_timezone; use crate::date::utils::parse_date_from_string; -use chrono::{DateTime, Local, LocalResult}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; - -use chrono::{FixedOffset, TimeZone}; +use chrono::{DateTime, FixedOffset, Local, LocalResult, TimeZone}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/debug/ast.rs b/crates/nu-command/src/debug/ast.rs index 370f2f24450a..d097dce5f60d 100644 --- a/crates/nu-command/src/debug/ast.rs +++ b/crates/nu-command/src/debug/ast.rs @@ -1,11 +1,6 @@ -use nu_engine::CallExt; +use nu_engine::command_prelude::*; use nu_parser::parse; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack, StateWorkingSet}, - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, -}; +use nu_protocol::engine::StateWorkingSet; #[derive(Clone)] pub struct Ast; diff --git a/crates/nu-command/src/debug/debug_.rs b/crates/nu-command/src/debug/debug_.rs index ffd6bc90d7cb..c76608141052 100644 --- a/crates/nu-command/src/debug/debug_.rs +++ b/crates/nu-command/src/debug/debug_.rs @@ -1,7 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Debug; diff --git a/crates/nu-command/src/debug/explain.rs b/crates/nu-command/src/debug/explain.rs index 8ac5bb14a2a9..9854d664cdc9 100644 --- a/crates/nu-command/src/debug/explain.rs +++ b/crates/nu-command/src/debug/explain.rs @@ -1,10 +1,7 @@ -use nu_engine::{get_eval_expression, CallExt}; -use nu_protocol::ast::{Argument, Block, Call, Expr, Expression}; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; +use nu_engine::{command_prelude::*, get_eval_expression}; use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, - Span, SyntaxShape, Type, Value, + ast::{Argument, Block, Expr, Expression}, + engine::Closure, }; #[derive(Clone)] diff --git a/crates/nu-command/src/debug/info.rs b/crates/nu-command/src/debug/info.rs index 733aa6c154d5..95f79af4a147 100644 --- a/crates/nu-command/src/debug/info.rs +++ b/crates/nu-command/src/debug/info.rs @@ -1,10 +1,7 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, LazyRecord, PipelineData, Record, ShellError, - Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::LazyRecord; use sysinfo::{MemoryRefreshKind, Pid, ProcessRefreshKind, RefreshKind, System}; + const ENV_PATH_SEPARATOR_CHAR: char = { #[cfg(target_family = "windows")] { diff --git a/crates/nu-command/src/debug/inspect.rs b/crates/nu-command/src/debug/inspect.rs index bed894311abc..681d2ef6c641 100644 --- a/crates/nu-command/src/debug/inspect.rs +++ b/crates/nu-command/src/debug/inspect.rs @@ -1,9 +1,5 @@ use super::inspect_table; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, -}; +use nu_engine::command_prelude::*; use terminal_size::{terminal_size, Height, Width}; #[derive(Clone)] diff --git a/crates/nu-command/src/debug/inspect_table.rs b/crates/nu-command/src/debug/inspect_table.rs index 0314b0c14e56..d2a112c70e12 100644 --- a/crates/nu-command/src/debug/inspect_table.rs +++ b/crates/nu-command/src/debug/inspect_table.rs @@ -1,3 +1,6 @@ +use crate::debug::inspect_table::{ + global_horizontal_char::SetHorizontalChar, set_widths::SetWidths, +}; use nu_protocol::Value; use nu_table::{string_width, string_wrap}; use tabled::{ @@ -6,10 +9,6 @@ use tabled::{ Table, }; -use crate::debug::inspect_table::{ - global_horizontal_char::SetHorizontalChar, set_widths::SetWidths, -}; - pub fn build_table(value: Value, description: String, termsize: usize) -> String { let (head, mut data) = util::collect_input(value); let count_columns = head.len(); diff --git a/crates/nu-command/src/debug/metadata.rs b/crates/nu-command/src/debug/metadata.rs index 61991cb1d3d0..d8856605e5ff 100644 --- a/crates/nu-command/src/debug/metadata.rs +++ b/crates/nu-command/src/debug/metadata.rs @@ -1,9 +1,7 @@ -use nu_engine::CallExt; -use nu_protocol::ast::{Call, Expr, Expression}; -use nu_protocol::engine::{Command, EngineState, Stack}; +use nu_engine::command_prelude::*; use nu_protocol::{ - record, Category, DataSource, Example, IntoPipelineData, PipelineData, PipelineMetadata, - Record, ShellError, Signature, Span, SyntaxShape, Type, Value, + ast::{Expr, Expression}, + DataSource, PipelineMetadata, }; #[derive(Clone)] diff --git a/crates/nu-command/src/debug/profile.rs b/crates/nu-command/src/debug/profile.rs index 2127c09d64d6..f274e7bd9817 100644 --- a/crates/nu-command/src/debug/profile.rs +++ b/crates/nu-command/src/debug/profile.rs @@ -1,9 +1,7 @@ -use nu_engine::{eval_block_with_early_return, CallExt}; -use nu_protocol::ast::Call; -use nu_protocol::debugger::{Profiler, WithDebug}; -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; +use nu_engine::{command_prelude::*, eval_block_with_early_return}; use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, + debugger::{Profiler, WithDebug}, + engine::Closure, }; #[derive(Clone)] diff --git a/crates/nu-command/src/debug/timeit.rs b/crates/nu-command/src/debug/timeit.rs index 85d811476c2e..0dcf85725fcf 100644 --- a/crates/nu-command/src/debug/timeit.rs +++ b/crates/nu-command/src/debug/timeit.rs @@ -1,11 +1,4 @@ -use nu_engine::{get_eval_block, get_eval_expression_with_input}; - -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, - Value, -}; +use nu_engine::{command_prelude::*, get_eval_block, get_eval_expression_with_input}; use std::time::Instant; #[derive(Clone)] diff --git a/crates/nu-command/src/debug/view.rs b/crates/nu-command/src/debug/view.rs index 9d644ff7e9f2..38a4efc2e765 100644 --- a/crates/nu-command/src/debug/view.rs +++ b/crates/nu-command/src/debug/view.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct View; diff --git a/crates/nu-command/src/debug/view_files.rs b/crates/nu-command/src/debug/view_files.rs index 914e86c3c8ba..4ddacb223777 100644 --- a/crates/nu-command/src/debug/view_files.rs +++ b/crates/nu-command/src/debug/view_files.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ViewFiles; diff --git a/crates/nu-command/src/debug/view_source.rs b/crates/nu-command/src/debug/view_source.rs index 771f7689cd2c..d4ab355e6c6f 100644 --- a/crates/nu-command/src/debug/view_source.rs +++ b/crates/nu-command/src/debug/view_source.rs @@ -1,10 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, - Value, -}; +use nu_engine::command_prelude::*; + use std::fmt::Write; #[derive(Clone)] diff --git a/crates/nu-command/src/debug/view_span.rs b/crates/nu-command/src/debug/view_span.rs index adc648f1bfb1..abf8e622b109 100644 --- a/crates/nu-command/src/debug/view_span.rs +++ b/crates/nu-command/src/debug/view_span.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct ViewSpan; diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index dc27d5d2ce54..2c98a4f46bc9 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -1,9 +1,9 @@ -use nu_protocol::engine::{EngineState, StateWorkingSet}; - use crate::{ help::{HelpAliases, HelpCommands, HelpEscapes, HelpExterns, HelpModules, HelpOperators}, *, }; +use nu_protocol::engine::{EngineState, StateWorkingSet}; + pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState { let delta = { let mut working_set = StateWorkingSet::new(&engine_state); diff --git a/crates/nu-command/src/env/config/config_.rs b/crates/nu-command/src/env/config/config_.rs index 6a2a483caf61..30285c5c9e2b 100644 --- a/crates/nu-command/src/env/config/config_.rs +++ b/crates/nu-command/src/env/config/config_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct ConfigMeta; diff --git a/crates/nu-command/src/env/config/config_env.rs b/crates/nu-command/src/env/config/config_env.rs index 75ec8c9658f1..2bcb3bc17578 100644 --- a/crates/nu-command/src/env/config/config_env.rs +++ b/crates/nu-command/src/env/config/config_env.rs @@ -1,12 +1,6 @@ -use nu_engine::{env_to_strings, CallExt}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; - use super::utils::gen_command; use nu_cmd_base::util::get_editor; +use nu_engine::{command_prelude::*, env_to_strings}; #[derive(Clone)] pub struct ConfigEnv; diff --git a/crates/nu-command/src/env/config/config_nu.rs b/crates/nu-command/src/env/config/config_nu.rs index b40a75db9b11..835926fa84cc 100644 --- a/crates/nu-command/src/env/config/config_nu.rs +++ b/crates/nu-command/src/env/config/config_nu.rs @@ -1,12 +1,6 @@ -use nu_engine::{env_to_strings, CallExt}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; - use super::utils::gen_command; use nu_cmd_base::util::get_editor; +use nu_engine::{command_prelude::*, env_to_strings}; #[derive(Clone)] pub struct ConfigNu; diff --git a/crates/nu-command/src/env/config/config_reset.rs b/crates/nu-command/src/env/config/config_reset.rs index 95afe4c7dd99..9a97285240d4 100644 --- a/crates/nu-command/src/env/config/config_reset.rs +++ b/crates/nu-command/src/env/config/config_reset.rs @@ -1,10 +1,6 @@ use chrono::Local; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Type, -}; +use nu_engine::command_prelude::*; + use nu_utils::{get_default_config, get_default_env}; use std::io::Write; diff --git a/crates/nu-command/src/env/config/utils.rs b/crates/nu-command/src/env/config/utils.rs index 029f0864f3be..48a648a1fa94 100644 --- a/crates/nu-command/src/env/config/utils.rs +++ b/crates/nu-command/src/env/config/utils.rs @@ -1,9 +1,6 @@ -use std::collections::HashMap; -use std::path::PathBuf; - -use nu_protocol::{IoStream, Span, Spanned}; - use crate::ExternalCommand; +use nu_protocol::{IoStream, Span, Spanned}; +use std::{collections::HashMap, path::PathBuf}; pub(crate) fn gen_command( span: Span, diff --git a/crates/nu-command/src/env/export_env.rs b/crates/nu-command/src/env/export_env.rs index fd13151dfdb7..89aaa17a3bb3 100644 --- a/crates/nu-command/src/env/export_env.rs +++ b/crates/nu-command/src/env/export_env.rs @@ -1,10 +1,5 @@ -use nu_engine::{get_eval_block, redirect_env, CallExt}; - -use nu_protocol::{ - ast::Call, - engine::{Closure, Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block, redirect_env}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct ExportEnv; diff --git a/crates/nu-command/src/env/load_env.rs b/crates/nu-command/src/env/load_env.rs index 5c65081b1274..0eba17528f47 100644 --- a/crates/nu-command/src/env/load_env.rs +++ b/crates/nu-command/src/env/load_env.rs @@ -1,9 +1,4 @@ -use nu_engine::{current_dir, CallExt}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, Record, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, current_dir}; #[derive(Clone)] pub struct LoadEnv; diff --git a/crates/nu-command/src/env/source_env.rs b/crates/nu-command/src/env/source_env.rs index 88f049230863..71c1e6dc3ff6 100644 --- a/crates/nu-command/src/env/source_env.rs +++ b/crates/nu-command/src/env/source_env.rs @@ -1,15 +1,8 @@ -use std::path::PathBuf; - use nu_engine::{ - find_in_dirs_env, get_dirs_var_from_call, get_eval_block_with_early_return, redirect_env, - CallExt, -}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, + command_prelude::*, find_in_dirs_env, get_dirs_var_from_call, get_eval_block_with_early_return, + redirect_env, }; +use std::path::PathBuf; /// Source a file for environment variables. #[derive(Clone)] diff --git a/crates/nu-command/src/env/with_env.rs b/crates/nu-command/src/env/with_env.rs index 39abd55db33f..5bd675e84a65 100644 --- a/crates/nu-command/src/env/with_env.rs +++ b/crates/nu-command/src/env/with_env.rs @@ -1,13 +1,7 @@ +use nu_engine::{command_prelude::*, eval_block}; +use nu_protocol::{debugger::WithoutDebug, engine::Closure}; use std::collections::HashMap; -use nu_engine::{eval_block, CallExt}; -use nu_protocol::debugger::WithoutDebug; -use nu_protocol::{ - ast::Call, - engine::{Closure, Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; - #[derive(Clone)] pub struct WithEnv; diff --git a/crates/nu-command/src/experimental/is_admin.rs b/crates/nu-command/src/experimental/is_admin.rs index e2263fe8d288..f6a2efef0af6 100644 --- a/crates/nu-command/src/experimental/is_admin.rs +++ b/crates/nu-command/src/experimental/is_admin.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct IsAdmin; diff --git a/crates/nu-command/src/filesystem/cd.rs b/crates/nu-command/src/filesystem/cd.rs index 1084188bd98c..80454d9e9929 100644 --- a/crates/nu-command/src/filesystem/cd.rs +++ b/crates/nu-command/src/filesystem/cd.rs @@ -1,11 +1,6 @@ #[cfg(unix)] use libc::gid_t; -use nu_engine::{current_dir, CallExt}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, current_dir}; use std::path::Path; // For checking whether we have permission to cd to a directory diff --git a/crates/nu-command/src/filesystem/du.rs b/crates/nu-command/src/filesystem/du.rs index cb1c5572c8c2..f6a27031f7d0 100644 --- a/crates/nu-command/src/filesystem/du.rs +++ b/crates/nu-command/src/filesystem/du.rs @@ -1,13 +1,8 @@ use super::util::opt_for_glob_pattern; use crate::{DirBuilder, DirInfo, FileInfo}; -use nu_engine::{current_dir, CallExt}; +use nu_engine::{command_prelude::*, current_dir}; use nu_glob::Pattern; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoInterruptiblePipelineData, NuGlob, PipelineData, ShellError, Signature, - Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_protocol::NuGlob; use serde::Deserialize; #[derive(Clone)] diff --git a/crates/nu-command/src/filesystem/glob.rs b/crates/nu-command/src/filesystem/glob.rs index 2a0defa05ab6..993d1fcb13ed 100644 --- a/crates/nu-command/src/filesystem/glob.rs +++ b/crates/nu-command/src/filesystem/glob.rs @@ -1,13 +1,5 @@ -use nu_engine::env::current_dir; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, -}; -use std::sync::atomic::AtomicBool; -use std::sync::Arc; +use nu_engine::{command_prelude::*, env::current_dir}; +use std::sync::{atomic::AtomicBool, Arc}; use wax::{Glob as WaxGlob, WalkBehavior, WalkEntry}; #[derive(Clone)] diff --git a/crates/nu-command/src/filesystem/ls.rs b/crates/nu-command/src/filesystem/ls.rs index b7f0133cf202..10c1f2174705 100644 --- a/crates/nu-command/src/filesystem/ls.rs +++ b/crates/nu-command/src/filesystem/ls.rs @@ -1,25 +1,19 @@ use super::util::opt_for_glob_pattern; -use crate::DirBuilder; -use crate::DirInfo; +use crate::{DirBuilder, DirInfo}; use chrono::{DateTime, Local, LocalResult, TimeZone, Utc}; -use nu_engine::env::current_dir; -use nu_engine::CallExt; +use nu_engine::{command_prelude::*, env::current_dir}; use nu_glob::{MatchOptions, Pattern}; use nu_path::expand_to_real_path; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::NuGlob; -use nu_protocol::{ - Category, DataSource, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - PipelineMetadata, Record, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_protocol::{DataSource, NuGlob, PipelineMetadata}; use pathdiff::diff_paths; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; -use std::path::PathBuf; -use std::sync::Arc; -use std::time::{SystemTime, UNIX_EPOCH}; +use std::{ + path::PathBuf, + sync::Arc, + time::{SystemTime, UNIX_EPOCH}, +}; #[derive(Clone)] pub struct Ls; diff --git a/crates/nu-command/src/filesystem/mktemp.rs b/crates/nu-command/src/filesystem/mktemp.rs index ce2b30582106..c6f51fb7d439 100644 --- a/crates/nu-command/src/filesystem/mktemp.rs +++ b/crates/nu-command/src/filesystem/mktemp.rs @@ -1,10 +1,4 @@ -use nu_engine::env::current_dir; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, env::current_dir}; use std::path::PathBuf; #[derive(Clone)] diff --git a/crates/nu-command/src/filesystem/open.rs b/crates/nu-command/src/filesystem/open.rs index dec947c84b9a..623d95baaf20 100644 --- a/crates/nu-command/src/filesystem/open.rs +++ b/crates/nu-command/src/filesystem/open.rs @@ -1,13 +1,7 @@ use super::util::get_rest_for_glob_pattern; -use nu_engine::{current_dir, get_eval_block, CallExt}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::util::BufferedReader; -use nu_protocol::{ - Category, DataSource, Example, IntoInterruptiblePipelineData, NuGlob, PipelineData, - PipelineMetadata, RawStream, ShellError, Signature, Spanned, SyntaxShape, Type, -}; -use std::io::BufReader; +use nu_engine::{command_prelude::*, current_dir, get_eval_block}; +use nu_protocol::{BufferedReader, DataSource, NuGlob, PipelineMetadata, RawStream}; +use std::{io::BufReader, path::Path}; #[cfg(feature = "sqlite")] use crate::database::SQLiteDatabase; @@ -17,7 +11,6 @@ use nu_protocol::IntoPipelineData; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; -use std::path::Path; #[derive(Clone)] pub struct Open; diff --git a/crates/nu-command/src/filesystem/rm.rs b/crates/nu-command/src/filesystem/rm.rs index 52e47aa18ae1..2795ebc9479d 100644 --- a/crates/nu-command/src/filesystem/rm.rs +++ b/crates/nu-command/src/filesystem/rm.rs @@ -1,22 +1,14 @@ -use std::collections::HashMap; -use std::io::Error; -use std::io::ErrorKind; -#[cfg(unix)] -use std::os::unix::prelude::FileTypeExt; -use std::path::PathBuf; - -use super::util::get_rest_for_glob_pattern; -use super::util::try_interaction; - -use nu_engine::env::current_dir; -use nu_engine::CallExt; +use super::util::{get_rest_for_glob_pattern, try_interaction}; +use nu_engine::{command_prelude::*, env::current_dir}; use nu_glob::MatchOptions; use nu_path::expand_path_with; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, NuGlob, PipelineData, ShellError, Signature, - Span, Spanned, SyntaxShape, Type, Value, +use nu_protocol::NuGlob; +#[cfg(unix)] +use std::os::unix::prelude::FileTypeExt; +use std::{ + collections::HashMap, + io::{Error, ErrorKind}, + path::PathBuf, }; const TRASH_SUPPORTED: bool = cfg!(all( diff --git a/crates/nu-command/src/filesystem/save.rs b/crates/nu-command/src/filesystem/save.rs index 0b6e7b5f700d..6e6630be8042 100644 --- a/crates/nu-command/src/filesystem/save.rs +++ b/crates/nu-command/src/filesystem/save.rs @@ -1,19 +1,16 @@ -use nu_engine::current_dir; -use nu_engine::CallExt; +use crate::progress_bar; +use nu_engine::{command_prelude::*, current_dir}; use nu_path::expand_path_with; -use nu_protocol::ast::{Call, Expr, Expression}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::IntoSpanned; use nu_protocol::{ - Category, DataSource, Example, IoStream, PipelineData, PipelineMetadata, RawStream, ShellError, - Signature, Span, Spanned, SyntaxShape, Type, Value, + ast::{Expr, Expression}, + DataSource, IoStream, PipelineMetadata, RawStream, +}; +use std::{ + fs::File, + io::Write, + path::{Path, PathBuf}, + thread, }; -use std::fs::File; -use std::io::Write; -use std::path::{Path, PathBuf}; -use std::thread; - -use crate::progress_bar; #[derive(Clone)] pub struct Save; diff --git a/crates/nu-command/src/filesystem/start.rs b/crates/nu-command/src/filesystem/start.rs index c08dd7181fa0..87aa34cf7272 100644 --- a/crates/nu-command/src/filesystem/start.rs +++ b/crates/nu-command/src/filesystem/start.rs @@ -1,15 +1,11 @@ use itertools::Itertools; -use nu_engine::env_to_strings; -use nu_engine::CallExt; +use nu_engine::{command_prelude::*, env_to_strings}; use nu_path::canonicalize_with; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, +use std::{ + ffi::{OsStr, OsString}, + path::Path, + process::Stdio, }; -use std::ffi::{OsStr, OsString}; -use std::path::Path; -use std::process::Stdio; #[derive(Clone)] pub struct Start; diff --git a/crates/nu-command/src/filesystem/touch.rs b/crates/nu-command/src/filesystem/touch.rs index 1f0ec4fa3fcb..f9e6cc10ed37 100644 --- a/crates/nu-command/src/filesystem/touch.rs +++ b/crates/nu-command/src/filesystem/touch.rs @@ -1,14 +1,7 @@ -use std::path::Path; -use std::{fs::OpenOptions, time::SystemTime}; - use filetime::FileTime; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, -}; +use std::{fs::OpenOptions, path::Path, time::SystemTime}; #[derive(Clone)] pub struct Touch; diff --git a/crates/nu-command/src/filesystem/ucp.rs b/crates/nu-command/src/filesystem/ucp.rs index 1ad98f28fc2d..79980e30dbfb 100644 --- a/crates/nu-command/src/filesystem/ucp.rs +++ b/crates/nu-command/src/filesystem/ucp.rs @@ -1,10 +1,5 @@ use super::util::get_rest_for_glob_pattern; -use nu_engine::{current_dir, CallExt}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, current_dir}; use std::path::PathBuf; use uu_cp::{BackupMode, CopyMode, UpdateMode}; diff --git a/crates/nu-command/src/filesystem/umkdir.rs b/crates/nu-command/src/filesystem/umkdir.rs index 1fc160257574..6fdda51eaddb 100644 --- a/crates/nu-command/src/filesystem/umkdir.rs +++ b/crates/nu-command/src/filesystem/umkdir.rs @@ -1,9 +1,6 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type}; -use std::path::PathBuf; +use nu_engine::command_prelude::*; +use std::path::PathBuf; use uu_mkdir::mkdir; #[cfg(not(windows))] use uucore::mode; diff --git a/crates/nu-command/src/filesystem/umv.rs b/crates/nu-command/src/filesystem/umv.rs index 72a4662134e3..b60a4f70ed1c 100644 --- a/crates/nu-command/src/filesystem/umv.rs +++ b/crates/nu-command/src/filesystem/umv.rs @@ -1,13 +1,8 @@ use super::util::get_rest_for_glob_pattern; -use nu_engine::current_dir; -use nu_engine::CallExt; +use nu_engine::{command_prelude::*, current_dir}; use nu_path::expand_path_with; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::NuGlob; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type}; -use std::ffi::OsString; -use std::path::PathBuf; +use std::{ffi::OsString, path::PathBuf}; use uu_mv::{BackupMode, UpdateMode}; #[derive(Clone)] diff --git a/crates/nu-command/src/filesystem/util.rs b/crates/nu-command/src/filesystem/util.rs index eb43b508736a..26cfd9372467 100644 --- a/crates/nu-command/src/filesystem/util.rs +++ b/crates/nu-command/src/filesystem/util.rs @@ -1,14 +1,10 @@ use dialoguer::Input; -use nu_engine::get_eval_expression; -use nu_protocol::ast::Expr; -use nu_protocol::{ - ast::Call, - engine::{EngineState, Stack}, - ShellError, Spanned, Value, +use nu_engine::{command_prelude::*, get_eval_expression}; +use nu_protocol::{ast::Expr, FromValue, NuGlob}; +use std::{ + error::Error, + path::{Path, PathBuf}, }; -use nu_protocol::{FromValue, NuGlob, Type}; -use std::error::Error; -use std::path::{Path, PathBuf}; #[derive(Debug, Eq, Ord, PartialEq, PartialOrd)] pub struct Resource { diff --git a/crates/nu-command/src/filesystem/watch.rs b/crates/nu-command/src/filesystem/watch.rs index a53bed7d7ba6..bbe87d497c21 100644 --- a/crates/nu-command/src/filesystem/watch.rs +++ b/crates/nu-command/src/filesystem/watch.rs @@ -1,7 +1,3 @@ -use std::path::PathBuf; -use std::sync::mpsc::{channel, RecvTimeoutError}; -use std::time::Duration; - use notify_debouncer_full::{ new_debouncer, notify::{ @@ -9,13 +5,15 @@ use notify_debouncer_full::{ EventKind, RecursiveMode, Watcher, }, }; -use nu_engine::{current_dir, get_eval_block, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack, StateWorkingSet}; +use nu_engine::{command_prelude::*, current_dir, get_eval_block}; use nu_protocol::{ - format_error, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, - Spanned, SyntaxShape, Type, Value, + engine::{Closure, StateWorkingSet}, + format_error, +}; +use std::{ + path::PathBuf, + sync::mpsc::{channel, RecvTimeoutError}, + time::Duration, }; // durations chosen mostly arbitrarily diff --git a/crates/nu-command/src/filters/all.rs b/crates/nu-command/src/filters/all.rs index 1bfb87690463..648454eb0732 100644 --- a/crates/nu-command/src/filters/all.rs +++ b/crates/nu-command/src/filters/all.rs @@ -1,10 +1,5 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; - use super::utils; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct All; diff --git a/crates/nu-command/src/filters/any.rs b/crates/nu-command/src/filters/any.rs index c0b87d35fed1..87d7887b4805 100644 --- a/crates/nu-command/src/filters/any.rs +++ b/crates/nu-command/src/filters/any.rs @@ -1,10 +1,5 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; - use super::utils; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Any; diff --git a/crates/nu-command/src/filters/append.rs b/crates/nu-command/src/filters/append.rs index d2800a16b6df..2ad5c2dbe4b3 100644 --- a/crates/nu-command/src/filters/append.rs +++ b/crates/nu-command/src/filters/append.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, - Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Append; diff --git a/crates/nu-command/src/filters/columns.rs b/crates/nu-command/src/filters/columns.rs index ae2f7d9338db..e7d8eec88a4c 100644 --- a/crates/nu-command/src/filters/columns.rs +++ b/crates/nu-command/src/filters/columns.rs @@ -1,10 +1,4 @@ -use nu_engine::column::get_columns; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, - Type, Value, -}; +use nu_engine::{column::get_columns, command_prelude::*}; #[derive(Clone)] pub struct Columns; diff --git a/crates/nu-command/src/filters/compact.rs b/crates/nu-command/src/filters/compact.rs index 163be44f161c..d8872448be8f 100644 --- a/crates/nu-command/src/filters/compact.rs +++ b/crates/nu-command/src/filters/compact.rs @@ -1,8 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, engine::Command, engine::EngineState, engine::Stack, record, Category, Example, - PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Compact; diff --git a/crates/nu-command/src/filters/default.rs b/crates/nu-command/src/filters/default.rs index 74aac2318fa1..30619d0f26f4 100644 --- a/crates/nu-command/src/filters/default.rs +++ b/crates/nu-command/src/filters/default.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Default; diff --git a/crates/nu-command/src/filters/drop/column.rs b/crates/nu-command/src/filters/drop/column.rs index cf7e9d0350ad..1862ac51c36d 100644 --- a/crates/nu-command/src/filters/drop/column.rs +++ b/crates/nu-command/src/filters/drop/column.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; use std::collections::HashSet; diff --git a/crates/nu-command/src/filters/drop/drop_.rs b/crates/nu-command/src/filters/drop/drop_.rs index 738f74d18f71..ea180d9816e4 100644 --- a/crates/nu-command/src/filters/drop/drop_.rs +++ b/crates/nu-command/src/filters/drop/drop_.rs @@ -1,11 +1,4 @@ -use nu_engine::CallExt; - -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Drop; diff --git a/crates/nu-command/src/filters/drop/nth.rs b/crates/nu-command/src/filters/drop/nth.rs index 2efd8fe0eda7..bd43f2f6ec37 100644 --- a/crates/nu-command/src/filters/drop/nth.rs +++ b/crates/nu-command/src/filters/drop/nth.rs @@ -1,11 +1,6 @@ use itertools::Either; -use nu_engine::CallExt; -use nu_protocol::ast::{Call, RangeInclusion}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, PipelineIterator, Range, - ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::{ast::RangeInclusion, PipelineIterator, Range}; #[derive(Clone)] pub struct DropNth; diff --git a/crates/nu-command/src/filters/each.rs b/crates/nu-command/src/filters/each.rs index b039b58ad689..98db34c4f5eb 100644 --- a/crates/nu-command/src/filters/each.rs +++ b/crates/nu-command/src/filters/each.rs @@ -1,13 +1,6 @@ -use nu_engine::{get_eval_block_with_early_return, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, - Signature, Span, SyntaxShape, Type, Value, -}; - use super::utils::chain_error_with_input; +use nu_engine::{command_prelude::*, get_eval_block_with_early_return}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct Each; diff --git a/crates/nu-command/src/filters/empty.rs b/crates/nu-command/src/filters/empty.rs index 855f87d7cfa7..e75700f26d28 100644 --- a/crates/nu-command/src/filters/empty.rs +++ b/crates/nu-command/src/filters/empty.rs @@ -1,7 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{EngineState, Stack}; -use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Value}; +use nu_engine::command_prelude::*; pub fn empty( engine_state: &EngineState, diff --git a/crates/nu-command/src/filters/enumerate.rs b/crates/nu-command/src/filters/enumerate.rs index e7fb72b4ff1a..e2e8d103eb47 100644 --- a/crates/nu-command/src/filters/enumerate.rs +++ b/crates/nu-command/src/filters/enumerate.rs @@ -1,9 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, - Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Enumerate; diff --git a/crates/nu-command/src/filters/every.rs b/crates/nu-command/src/filters/every.rs index 4e4d18386793..a7fc4f1b0261 100644 --- a/crates/nu-command/src/filters/every.rs +++ b/crates/nu-command/src/filters/every.rs @@ -1,11 +1,4 @@ -use nu_engine::CallExt; - -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Every; diff --git a/crates/nu-command/src/filters/filter.rs b/crates/nu-command/src/filters/filter.rs index 3ec7e14ee418..f66a01580d22 100644 --- a/crates/nu-command/src/filters/filter.rs +++ b/crates/nu-command/src/filters/filter.rs @@ -1,12 +1,6 @@ use super::utils::chain_error_with_input; -use nu_engine::{get_eval_block_with_early_return, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block_with_early_return}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct Filter; diff --git a/crates/nu-command/src/filters/find.rs b/crates/nu-command/src/filters/find.rs index 84362cda60e7..c84bc5be893e 100644 --- a/crates/nu-command/src/filters/find.rs +++ b/crates/nu-command/src/filters/find.rs @@ -1,15 +1,9 @@ use crate::help::highlight_search_string; - use fancy_regex::Regex; use nu_ansi_term::Style; use nu_color_config::StyleComputer; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Config, Example, IntoInterruptiblePipelineData, IntoPipelineData, ListStream, - PipelineData, Record, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::{Config, ListStream}; use nu_utils::IgnoreCaseExt; #[derive(Clone)] diff --git a/crates/nu-command/src/filters/first.rs b/crates/nu-command/src/filters/first.rs index 405887be1a82..ca575ebab189 100644 --- a/crates/nu-command/src/filters/first.rs +++ b/crates/nu-command/src/filters/first.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, - Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct First; diff --git a/crates/nu-command/src/filters/flatten.rs b/crates/nu-command/src/filters/flatten.rs index 836df345472b..f7f5a1325b79 100644 --- a/crates/nu-command/src/filters/flatten.rs +++ b/crates/nu-command/src/filters/flatten.rs @@ -1,12 +1,6 @@ use indexmap::IndexMap; -use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath, PathMember}; - -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, Record, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::ast::PathMember; #[derive(Clone)] pub struct Flatten; diff --git a/crates/nu-command/src/filters/get.rs b/crates/nu-command/src/filters/get.rs index 9a8c2c5666be..14d5169d2543 100644 --- a/crates/nu-command/src/filters/get.rs +++ b/crates/nu-command/src/filters/get.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, - Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Get; diff --git a/crates/nu-command/src/filters/group.rs b/crates/nu-command/src/filters/group.rs index baca1c5bbead..196d2f79c847 100644 --- a/crates/nu-command/src/filters/group.rs +++ b/crates/nu-command/src/filters/group.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Group; diff --git a/crates/nu-command/src/filters/group_by.rs b/crates/nu-command/src/filters/group_by.rs index e8fa87705a2f..604aa2a41f29 100644 --- a/crates/nu-command/src/filters/group_by.rs +++ b/crates/nu-command/src/filters/group_by.rs @@ -1,12 +1,6 @@ -use nu_engine::{get_eval_block, CallExt}; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, Record, ShellError, Signature, Span, - SyntaxShape, Type, Value, -}; - use indexmap::IndexMap; +use nu_engine::{command_prelude::*, get_eval_block}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct GroupBy; diff --git a/crates/nu-command/src/filters/headers.rs b/crates/nu-command/src/filters/headers.rs index 4d8927716ff0..0e3497701431 100644 --- a/crates/nu-command/src/filters/headers.rs +++ b/crates/nu-command/src/filters/headers.rs @@ -1,9 +1,5 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Config, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, - Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::Config; #[derive(Clone)] pub struct Headers; diff --git a/crates/nu-command/src/filters/insert.rs b/crates/nu-command/src/filters/insert.rs index 8feac01d9bcd..d4181f2b957d 100644 --- a/crates/nu-command/src/filters/insert.rs +++ b/crates/nu-command/src/filters/insert.rs @@ -1,10 +1,8 @@ -use nu_engine::{get_eval_block, CallExt, EvalBlockFn}; -use nu_protocol::ast::{Block, Call, CellPath, PathMember}; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; +use nu_engine::{command_prelude::*, get_eval_block, EvalBlockFn}; use nu_protocol::{ - record, Category, Example, FromValue, IntoInterruptiblePipelineData, IntoPipelineData, - PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, + ast::{Block, PathMember}, + engine::Closure, + FromValue, }; #[derive(Clone)] diff --git a/crates/nu-command/src/filters/interleave.rs b/crates/nu-command/src/filters/interleave.rs index 6e1e0fd265af..a4255ec94428 100644 --- a/crates/nu-command/src/filters/interleave.rs +++ b/crates/nu-command/src/filters/interleave.rs @@ -1,13 +1,7 @@ +use nu_engine::{command_prelude::*, get_eval_block_with_early_return}; +use nu_protocol::engine::Closure; use std::{sync::mpsc, thread}; -use nu_engine::{get_eval_block_with_early_return, CallExt}; -use nu_protocol::{ - ast::Call, - engine::{Closure, Command, EngineState, Stack}, - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, - SyntaxShape, Type, Value, -}; - #[derive(Clone)] pub struct Interleave; diff --git a/crates/nu-command/src/filters/is_empty.rs b/crates/nu-command/src/filters/is_empty.rs index 7619332bd5ed..d18f3d4cebff 100644 --- a/crates/nu-command/src/filters/is_empty.rs +++ b/crates/nu-command/src/filters/is_empty.rs @@ -1,9 +1,5 @@ use crate::filters::empty::empty; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct IsEmpty; diff --git a/crates/nu-command/src/filters/is_not_empty.rs b/crates/nu-command/src/filters/is_not_empty.rs index e99344b8cadf..6d97e3612d56 100644 --- a/crates/nu-command/src/filters/is_not_empty.rs +++ b/crates/nu-command/src/filters/is_not_empty.rs @@ -1,9 +1,5 @@ use crate::filters::empty::empty; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct IsNotEmpty; diff --git a/crates/nu-command/src/filters/items.rs b/crates/nu-command/src/filters/items.rs index 8da1116c883f..60c6b67acfc7 100644 --- a/crates/nu-command/src/filters/items.rs +++ b/crates/nu-command/src/filters/items.rs @@ -1,13 +1,6 @@ -use nu_engine::{get_eval_block_with_early_return, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, - SyntaxShape, Type, Value, -}; - use super::utils::chain_error_with_input; +use nu_engine::{command_prelude::*, get_eval_block_with_early_return}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct Items; diff --git a/crates/nu-command/src/filters/join.rs b/crates/nu-command/src/filters/join.rs index 565d5910b733..c1e90e902365 100644 --- a/crates/nu-command/src/filters/join.rs +++ b/crates/nu-command/src/filters/join.rs @@ -1,12 +1,9 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Config, Example, PipelineData, Record, ShellError, Signature, Span, - SyntaxShape, Type, Value, +use nu_engine::command_prelude::*; +use nu_protocol::Config; +use std::{ + cmp::max, + collections::{HashMap, HashSet}, }; -use std::cmp::max; -use std::collections::{HashMap, HashSet}; #[derive(Clone)] pub struct Join; diff --git a/crates/nu-command/src/filters/last.rs b/crates/nu-command/src/filters/last.rs index b76ef482151b..92d83d15957f 100644 --- a/crates/nu-command/src/filters/last.rs +++ b/crates/nu-command/src/filters/last.rs @@ -1,13 +1,6 @@ -use std::collections::VecDeque; - -use nu_engine::CallExt; +use nu_engine::command_prelude::*; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, - Signature, Span, SyntaxShape, Type, Value, -}; +use std::collections::VecDeque; #[derive(Clone)] pub struct Last; diff --git a/crates/nu-command/src/filters/length.rs b/crates/nu-command/src/filters/length.rs index a5e3c0f9257d..cced0a95154e 100644 --- a/crates/nu-command/src/filters/length.rs +++ b/crates/nu-command/src/filters/length.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Length; diff --git a/crates/nu-command/src/filters/lines.rs b/crates/nu-command/src/filters/lines.rs index f97bdac78a9f..53360001db0c 100644 --- a/crates/nu-command/src/filters/lines.rs +++ b/crates/nu-command/src/filters/lines.rs @@ -1,13 +1,7 @@ +use nu_engine::command_prelude::*; +use nu_protocol::RawStream; use std::collections::VecDeque; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, RawStream, - ShellError, Signature, Span, Type, Value, -}; - #[derive(Clone)] pub struct Lines; diff --git a/crates/nu-command/src/filters/merge.rs b/crates/nu-command/src/filters/merge.rs index 982122580ac1..157594b6e72b 100644 --- a/crates/nu-command/src/filters/merge.rs +++ b/crates/nu-command/src/filters/merge.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - Record, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Merge; diff --git a/crates/nu-command/src/filters/move_.rs b/crates/nu-command/src/filters/move_.rs index bc8e6dca9582..d4317e1c39fe 100644 --- a/crates/nu-command/src/filters/move_.rs +++ b/crates/nu-command/src/filters/move_.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - Record, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone, Debug)] enum BeforeOrAfter { diff --git a/crates/nu-command/src/filters/par_each.rs b/crates/nu-command/src/filters/par_each.rs index ebda3c7b6f71..096ab9655fde 100644 --- a/crates/nu-command/src/filters/par_each.rs +++ b/crates/nu-command/src/filters/par_each.rs @@ -1,11 +1,5 @@ -use nu_engine::{get_eval_block_with_early_return, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, - Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block_with_early_return}; +use nu_protocol::engine::Closure; use rayon::prelude::*; use super::utils::chain_error_with_input; diff --git a/crates/nu-command/src/filters/prepend.rs b/crates/nu-command/src/filters/prepend.rs index 6f57d532cdd6..cef8ce8c1a13 100644 --- a/crates/nu-command/src/filters/prepend.rs +++ b/crates/nu-command/src/filters/prepend.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, - Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Prepend; diff --git a/crates/nu-command/src/filters/range.rs b/crates/nu-command/src/filters/range.rs index 59d2ba0ec2ea..db245b4d2ce3 100644 --- a/crates/nu-command/src/filters/range.rs +++ b/crates/nu-command/src/filters/range.rs @@ -1,11 +1,5 @@ -use nu_engine::CallExt; - -use nu_protocol::ast::{Call, RangeInclusion}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::ast::RangeInclusion; #[derive(Clone)] pub struct Range; diff --git a/crates/nu-command/src/filters/reduce.rs b/crates/nu-command/src/filters/reduce.rs index 0e539d6f8d42..e708dec10b60 100644 --- a/crates/nu-command/src/filters/reduce.rs +++ b/crates/nu-command/src/filters/reduce.rs @@ -1,12 +1,5 @@ -use nu_engine::{get_eval_block_with_early_return, CallExt}; - -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, - Value, -}; +use nu_engine::{command_prelude::*, get_eval_block_with_early_return}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct Reduce; diff --git a/crates/nu-command/src/filters/reject.rs b/crates/nu-command/src/filters/reject.rs index db7ddcb80e93..23f36ec1722b 100644 --- a/crates/nu-command/src/filters/reject.rs +++ b/crates/nu-command/src/filters/reject.rs @@ -1,12 +1,6 @@ -use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath, PathMember}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, - SyntaxShape, Type, Value, -}; -use std::cmp::Reverse; -use std::collections::HashSet; +use nu_engine::command_prelude::*; +use nu_protocol::ast::PathMember; +use std::{cmp::Reverse, collections::HashSet}; #[derive(Clone)] pub struct Reject; diff --git a/crates/nu-command/src/filters/rename.rs b/crates/nu-command/src/filters/rename.rs index 7b597f7e5915..bc05153217fb 100644 --- a/crates/nu-command/src/filters/rename.rs +++ b/crates/nu-command/src/filters/rename.rs @@ -1,12 +1,6 @@ use indexmap::IndexMap; -use nu_engine::{get_eval_block_with_early_return, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, Record, ShellError, Signature, - SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block_with_early_return}; +use nu_protocol::engine::Closure; use std::collections::HashSet; #[derive(Clone)] diff --git a/crates/nu-command/src/filters/reverse.rs b/crates/nu-command/src/filters/reverse.rs index e31260dd64ba..db39ee3bd579 100644 --- a/crates/nu-command/src/filters/reverse.rs +++ b/crates/nu-command/src/filters/reverse.rs @@ -1,9 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, - Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Reverse; diff --git a/crates/nu-command/src/filters/select.rs b/crates/nu-command/src/filters/select.rs index 474e2161b499..dc9da1054cef 100644 --- a/crates/nu-command/src/filters/select.rs +++ b/crates/nu-command/src/filters/select.rs @@ -1,10 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath, PathMember}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - PipelineIterator, Record, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::{ast::PathMember, PipelineIterator}; use std::collections::BTreeSet; #[derive(Clone)] diff --git a/crates/nu-command/src/filters/shuffle.rs b/crates/nu-command/src/filters/shuffle.rs index 3afc9c6f4250..598a292e5dee 100644 --- a/crates/nu-command/src/filters/shuffle.rs +++ b/crates/nu-command/src/filters/shuffle.rs @@ -1,10 +1,5 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Type, -}; -use rand::prelude::SliceRandom; -use rand::thread_rng; +use nu_engine::command_prelude::*; +use rand::{prelude::SliceRandom, thread_rng}; #[derive(Clone)] pub struct Shuffle; diff --git a/crates/nu-command/src/filters/skip/skip_.rs b/crates/nu-command/src/filters/skip/skip_.rs index 240d2674ef0c..54689c218cc9 100644 --- a/crates/nu-command/src/filters/skip/skip_.rs +++ b/crates/nu-command/src/filters/skip/skip_.rs @@ -1,12 +1,6 @@ -use std::convert::TryInto; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - ShellError, Signature, SyntaxShape, Type, Value, -}; +use std::convert::TryInto; #[derive(Clone)] pub struct Skip; diff --git a/crates/nu-command/src/filters/skip/skip_until.rs b/crates/nu-command/src/filters/skip/skip_until.rs index bef27802233f..de952eecbae0 100644 --- a/crates/nu-command/src/filters/skip/skip_until.rs +++ b/crates/nu-command/src/filters/skip/skip_until.rs @@ -1,11 +1,5 @@ -use nu_engine::{get_eval_block, CallExt}; - -use nu_protocol::{ - ast::Call, - engine::{Closure, Command, EngineState, Stack}, - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, - SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct SkipUntil; diff --git a/crates/nu-command/src/filters/skip/skip_while.rs b/crates/nu-command/src/filters/skip/skip_while.rs index 3460c2f493d6..c47aef50e61e 100644 --- a/crates/nu-command/src/filters/skip/skip_while.rs +++ b/crates/nu-command/src/filters/skip/skip_while.rs @@ -1,11 +1,5 @@ -use nu_engine::{get_eval_block, CallExt}; - -use nu_protocol::{ - ast::Call, - engine::{Closure, Command, EngineState, Stack}, - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, - SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct SkipWhile; diff --git a/crates/nu-command/src/filters/sort.rs b/crates/nu-command/src/filters/sort.rs index b0ca9e7f889c..cd0818a8c959 100644 --- a/crates/nu-command/src/filters/sort.rs +++ b/crates/nu-command/src/filters/sort.rs @@ -1,11 +1,6 @@ use alphanumeric_sort::compare_str; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - Record, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; + use nu_utils::IgnoreCaseExt; use std::cmp::Ordering; diff --git a/crates/nu-command/src/filters/sort_by.rs b/crates/nu-command/src/filters/sort_by.rs index 6b8d15e139fd..5c0d173945d7 100644 --- a/crates/nu-command/src/filters/sort_by.rs +++ b/crates/nu-command/src/filters/sort_by.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SortBy; diff --git a/crates/nu-command/src/filters/split_by.rs b/crates/nu-command/src/filters/split_by.rs index 6686d9ea1f2a..7dea03a6e637 100644 --- a/crates/nu-command/src/filters/split_by.rs +++ b/crates/nu-command/src/filters/split_by.rs @@ -1,11 +1,5 @@ use indexmap::IndexMap; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SplitBy; diff --git a/crates/nu-command/src/filters/take/take_.rs b/crates/nu-command/src/filters/take/take_.rs index d56437f55189..2586942e4cd0 100644 --- a/crates/nu-command/src/filters/take/take_.rs +++ b/crates/nu-command/src/filters/take/take_.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Take; diff --git a/crates/nu-command/src/filters/take/take_until.rs b/crates/nu-command/src/filters/take/take_until.rs index e4f9c47b6eec..7e92c942f693 100644 --- a/crates/nu-command/src/filters/take/take_until.rs +++ b/crates/nu-command/src/filters/take/take_until.rs @@ -1,11 +1,5 @@ -use nu_engine::{get_eval_block, CallExt}; - -use nu_protocol::{ - ast::Call, - engine::{Closure, Command, EngineState, Stack}, - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, - SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct TakeUntil; diff --git a/crates/nu-command/src/filters/take/take_while.rs b/crates/nu-command/src/filters/take/take_while.rs index 99848c982959..de389f04ce10 100644 --- a/crates/nu-command/src/filters/take/take_while.rs +++ b/crates/nu-command/src/filters/take/take_while.rs @@ -1,10 +1,5 @@ -use nu_engine::{get_eval_block, CallExt}; -use nu_protocol::{ - ast::Call, - engine::{Closure, Command, EngineState, Stack}, - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, - SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct TakeWhile; diff --git a/crates/nu-command/src/filters/tee.rs b/crates/nu-command/src/filters/tee.rs index 85818488ab7a..3a710c5a18ea 100644 --- a/crates/nu-command/src/filters/tee.rs +++ b/crates/nu-command/src/filters/tee.rs @@ -1,13 +1,7 @@ +use nu_engine::{command_prelude::*, get_eval_block_with_early_return}; +use nu_protocol::{engine::Closure, IoStream, RawStream}; use std::{sync::mpsc, thread}; -use nu_engine::{get_eval_block_with_early_return, CallExt}; -use nu_protocol::{ - ast::Call, - engine::{Closure, Command, EngineState, Stack}, - Category, Example, IntoInterruptiblePipelineData, IntoSpanned, IoStream, PipelineData, - RawStream, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; - #[derive(Clone)] pub struct Tee; diff --git a/crates/nu-command/src/filters/transpose.rs b/crates/nu-command/src/filters/transpose.rs index e2b36b387c6e..b69f1d7240de 100644 --- a/crates/nu-command/src/filters/transpose.rs +++ b/crates/nu-command/src/filters/transpose.rs @@ -1,11 +1,4 @@ -use nu_engine::column::get_columns; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, Record, ShellError, - Signature, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::{column::get_columns, command_prelude::*}; #[derive(Clone)] pub struct Transpose; diff --git a/crates/nu-command/src/filters/uniq.rs b/crates/nu-command/src/filters/uniq.rs index f96906d4cec7..13e3e900bc75 100644 --- a/crates/nu-command/src/filters/uniq.rs +++ b/crates/nu-command/src/filters/uniq.rs @@ -1,15 +1,9 @@ use crate::formats::value_to_string; use itertools::Itertools; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, PipelineMetadata, ShellError, - Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::PipelineMetadata; use nu_utils::IgnoreCaseExt; -use std::collections::hash_map::IntoIter; -use std::collections::HashMap; +use std::collections::{hash_map::IntoIter, HashMap}; #[derive(Clone)] pub struct Uniq; diff --git a/crates/nu-command/src/filters/uniq_by.rs b/crates/nu-command/src/filters/uniq_by.rs index c6a1d47d6d3c..d6b87bd065b6 100644 --- a/crates/nu-command/src/filters/uniq_by.rs +++ b/crates/nu-command/src/filters/uniq_by.rs @@ -1,11 +1,5 @@ pub use super::uniq; -use nu_engine::column::nonexistent_column; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::{column::nonexistent_column, command_prelude::*}; #[derive(Clone)] pub struct UniqBy; diff --git a/crates/nu-command/src/filters/update.rs b/crates/nu-command/src/filters/update.rs index d8f9847bf370..7931100605e7 100644 --- a/crates/nu-command/src/filters/update.rs +++ b/crates/nu-command/src/filters/update.rs @@ -1,10 +1,8 @@ -use nu_engine::{get_eval_block, CallExt, EvalBlockFn}; -use nu_protocol::ast::{Block, Call, CellPath, PathMember}; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; +use nu_engine::{command_prelude::*, get_eval_block, EvalBlockFn}; use nu_protocol::{ - record, Category, Example, FromValue, IntoInterruptiblePipelineData, IntoPipelineData, - PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, + ast::{Block, PathMember}, + engine::Closure, + FromValue, }; #[derive(Clone)] diff --git a/crates/nu-command/src/filters/upsert.rs b/crates/nu-command/src/filters/upsert.rs index 05d81ea3b4d7..767d9d753399 100644 --- a/crates/nu-command/src/filters/upsert.rs +++ b/crates/nu-command/src/filters/upsert.rs @@ -1,10 +1,8 @@ -use nu_engine::{get_eval_block, CallExt, EvalBlockFn}; -use nu_protocol::ast::{Block, Call, CellPath, PathMember}; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; +use nu_engine::{command_prelude::*, get_eval_block, EvalBlockFn}; use nu_protocol::{ - record, Category, Example, FromValue, IntoInterruptiblePipelineData, IntoPipelineData, - PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, + ast::{Block, PathMember}, + engine::Closure, + FromValue, }; #[derive(Clone)] diff --git a/crates/nu-command/src/filters/utils.rs b/crates/nu-command/src/filters/utils.rs index 687ec1b684e4..c4d0fce108ba 100644 --- a/crates/nu-command/src/filters/utils.rs +++ b/crates/nu-command/src/filters/utils.rs @@ -1,5 +1,4 @@ use nu_engine::{get_eval_block, CallExt}; - use nu_protocol::{ ast::Call, engine::{Closure, EngineState, Stack}, diff --git a/crates/nu-command/src/filters/values.rs b/crates/nu-command/src/filters/values.rs index 5585dc0e5956..aafa211f17dd 100644 --- a/crates/nu-command/src/filters/values.rs +++ b/crates/nu-command/src/filters/values.rs @@ -1,10 +1,5 @@ use indexmap::IndexMap; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, - Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Values; diff --git a/crates/nu-command/src/filters/where_.rs b/crates/nu-command/src/filters/where_.rs index 766c04feb8b5..5062214a992f 100644 --- a/crates/nu-command/src/filters/where_.rs +++ b/crates/nu-command/src/filters/where_.rs @@ -1,11 +1,5 @@ -use nu_engine::{get_eval_block, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Closure, Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct Where; diff --git a/crates/nu-command/src/filters/window.rs b/crates/nu-command/src/filters/window.rs index ae7f4256c021..5c84ad7e988b 100644 --- a/crates/nu-command/src/filters/window.rs +++ b/crates/nu-command/src/filters/window.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Window; diff --git a/crates/nu-command/src/filters/wrap.rs b/crates/nu-command/src/filters/wrap.rs index 0299e7d87464..0954751f7128 100644 --- a/crates/nu-command/src/filters/wrap.rs +++ b/crates/nu-command/src/filters/wrap.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Wrap; diff --git a/crates/nu-command/src/filters/zip.rs b/crates/nu-command/src/filters/zip.rs index a4cdfc759ce9..a1e7ad4d4d93 100644 --- a/crates/nu-command/src/filters/zip.rs +++ b/crates/nu-command/src/filters/zip.rs @@ -1,10 +1,4 @@ -use nu_engine::{get_eval_block_with_early_return, CallExt}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, - Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block_with_early_return}; #[derive(Clone)] pub struct Zip; diff --git a/crates/nu-command/src/formats/from/command.rs b/crates/nu-command/src/formats/from/command.rs index c69f14fbac6c..ce5987e5b124 100644 --- a/crates/nu-command/src/formats/from/command.rs +++ b/crates/nu-command/src/formats/from/command.rs @@ -1,7 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct From; diff --git a/crates/nu-command/src/formats/from/csv.rs b/crates/nu-command/src/formats/from/csv.rs index c509fbbcb33f..a05d3e43f642 100644 --- a/crates/nu-command/src/formats/from/csv.rs +++ b/crates/nu-command/src/formats/from/csv.rs @@ -1,11 +1,5 @@ use super::delimited::{from_delimited_data, trim_from_str, DelimitedReaderConfig}; - -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct FromCsv; diff --git a/crates/nu-command/src/formats/from/json.rs b/crates/nu-command/src/formats/from/json.rs index af6dc13357a5..5baaea30dd38 100644 --- a/crates/nu-command/src/formats/from/json.rs +++ b/crates/nu-command/src/formats/from/json.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct FromJson; diff --git a/crates/nu-command/src/formats/from/nuon.rs b/crates/nu-command/src/formats/from/nuon.rs index b123c525eaec..e74c1fe5eb28 100644 --- a/crates/nu-command/src/formats/from/nuon.rs +++ b/crates/nu-command/src/formats/from/nuon.rs @@ -1,11 +1,11 @@ -use std::sync::Arc; - -use nu_protocol::ast::{Call, Expr, Expression, RecordItem}; -use nu_protocol::engine::{Command, EngineState, Stack, StateWorkingSet}; +use nu_engine::command_prelude::*; use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, Range, Record, ShellError, - Signature, Span, Type, Unit, Value, + ast::{Expr, Expression, RecordItem}, + engine::StateWorkingSet, + Range, Unit, }; +use std::sync::Arc; + #[derive(Clone)] pub struct FromNuon; diff --git a/crates/nu-command/src/formats/from/ods.rs b/crates/nu-command/src/formats/from/ods.rs index ced195503c4d..7e716c449363 100644 --- a/crates/nu-command/src/formats/from/ods.rs +++ b/crates/nu-command/src/formats/from/ods.rs @@ -1,11 +1,7 @@ use calamine::*; -use indexmap::map::IndexMap; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use indexmap::IndexMap; +use nu_engine::command_prelude::*; + use std::io::Cursor; #[derive(Clone)] diff --git a/crates/nu-command/src/formats/from/ssv.rs b/crates/nu-command/src/formats/from/ssv.rs index 7df3b809dae8..0380f66e2f75 100644 --- a/crates/nu-command/src/formats/from/ssv.rs +++ b/crates/nu-command/src/formats/from/ssv.rs @@ -1,11 +1,5 @@ -use indexmap::map::IndexMap; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, -}; +use indexmap::IndexMap; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct FromSsv; diff --git a/crates/nu-command/src/formats/from/toml.rs b/crates/nu-command/src/formats/from/toml.rs index 5af85cdeb2e8..46877d1dac9a 100644 --- a/crates/nu-command/src/formats/from/toml.rs +++ b/crates/nu-command/src/formats/from/toml.rs @@ -1,9 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, - Value, -}; +use nu_engine::command_prelude::*; use std::str::FromStr; #[derive(Clone)] diff --git a/crates/nu-command/src/formats/from/tsv.rs b/crates/nu-command/src/formats/from/tsv.rs index fb9c0533f400..5cbaeb9456f0 100644 --- a/crates/nu-command/src/formats/from/tsv.rs +++ b/crates/nu-command/src/formats/from/tsv.rs @@ -1,11 +1,5 @@ use super::delimited::{from_delimited_data, trim_from_str, DelimitedReaderConfig}; - -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct FromTsv; diff --git a/crates/nu-command/src/formats/from/xlsx.rs b/crates/nu-command/src/formats/from/xlsx.rs index d2fe3cfa0b7b..d5fb0bfb68a3 100644 --- a/crates/nu-command/src/formats/from/xlsx.rs +++ b/crates/nu-command/src/formats/from/xlsx.rs @@ -1,13 +1,8 @@ use calamine::*; -use chrono::offset::Utc; -use chrono::{Local, LocalResult, Offset, TimeZone}; -use indexmap::map::IndexMap; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use chrono::{Local, LocalResult, Offset, TimeZone, Utc}; +use indexmap::IndexMap; +use nu_engine::command_prelude::*; + use std::io::Cursor; #[derive(Clone)] diff --git a/crates/nu-command/src/formats/from/xml.rs b/crates/nu-command/src/formats/from/xml.rs index 433d2d323194..3443bf030946 100644 --- a/crates/nu-command/src/formats/from/xml.rs +++ b/crates/nu-command/src/formats/from/xml.rs @@ -1,12 +1,7 @@ use crate::formats::nu_xml_format::{COLUMN_ATTRS_NAME, COLUMN_CONTENT_NAME, COLUMN_TAG_NAME}; -use indexmap::map::IndexMap; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, Record, ShellError, Signature, Span, - Type, Value, -}; +use indexmap::IndexMap; +use nu_engine::command_prelude::*; + use roxmltree::NodeType; #[derive(Clone)] diff --git a/crates/nu-command/src/formats/from/yaml.rs b/crates/nu-command/src/formats/from/yaml.rs index abe38ef5cb99..5edb8bdac9df 100644 --- a/crates/nu-command/src/formats/from/yaml.rs +++ b/crates/nu-command/src/formats/from/yaml.rs @@ -1,11 +1,6 @@ use indexmap::IndexMap; use itertools::Itertools; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, - Value, -}; +use nu_engine::command_prelude::*; use serde::de::Deserialize; #[derive(Clone)] diff --git a/crates/nu-command/src/formats/to/command.rs b/crates/nu-command/src/formats/to/command.rs index 1e15c97c83f7..26c9a259b6de 100644 --- a/crates/nu-command/src/formats/to/command.rs +++ b/crates/nu-command/src/formats/to/command.rs @@ -1,7 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct To; diff --git a/crates/nu-command/src/formats/to/csv.rs b/crates/nu-command/src/formats/to/csv.rs index 1f58690c79ed..a3528080df2f 100644 --- a/crates/nu-command/src/formats/to/csv.rs +++ b/crates/nu-command/src/formats/to/csv.rs @@ -1,11 +1,6 @@ use crate::formats::to::delimited::to_delimited_data; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Config, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::Config; #[derive(Clone)] pub struct ToCsv; diff --git a/crates/nu-command/src/formats/to/delimited.rs b/crates/nu-command/src/formats/to/delimited.rs index 4bed0c4ec946..22c439fbc760 100644 --- a/crates/nu-command/src/formats/to/delimited.rs +++ b/crates/nu-command/src/formats/to/delimited.rs @@ -1,8 +1,7 @@ use csv::{Writer, WriterBuilder}; use nu_cmd_base::formats::to::delimited::merge_descriptors; use nu_protocol::{Config, IntoPipelineData, PipelineData, Record, ShellError, Span, Value}; -use std::collections::VecDeque; -use std::error::Error; +use std::{collections::VecDeque, error::Error}; fn from_value_to_delimited_string( value: &Value, diff --git a/crates/nu-command/src/formats/to/json.rs b/crates/nu-command/src/formats/to/json.rs index 08764d296a09..5a542d8e2c0f 100644 --- a/crates/nu-command/src/formats/to/json.rs +++ b/crates/nu-command/src/formats/to/json.rs @@ -1,10 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::{Call, PathMember}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, - Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::ast::PathMember; #[derive(Clone)] pub struct ToJson; diff --git a/crates/nu-command/src/formats/to/md.rs b/crates/nu-command/src/formats/to/md.rs index e80f3aae3917..e2acdd703e56 100644 --- a/crates/nu-command/src/formats/to/md.rs +++ b/crates/nu-command/src/formats/to/md.rs @@ -1,12 +1,7 @@ -use indexmap::map::IndexMap; +use indexmap::IndexMap; use nu_cmd_base::formats::to::delimited::merge_descriptors; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Config, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, - Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::Config; #[derive(Clone)] pub struct ToMd; diff --git a/crates/nu-command/src/formats/to/nuon.rs b/crates/nu-command/src/formats/to/nuon.rs index 783e747ca5f4..61137534ca70 100644 --- a/crates/nu-command/src/formats/to/nuon.rs +++ b/crates/nu-command/src/formats/to/nuon.rs @@ -1,14 +1,8 @@ use core::fmt::Write; use fancy_regex::Regex; -use nu_engine::get_columns; -use nu_engine::CallExt; +use nu_engine::{command_prelude::*, get_columns}; use nu_parser::escape_quote_string; -use nu_protocol::ast::{Call, RangeInclusion}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_protocol::ast::RangeInclusion; use once_cell::sync::Lazy; #[derive(Clone)] diff --git a/crates/nu-command/src/formats/to/text.rs b/crates/nu-command/src/formats/to/text.rs index a30729d7c893..e55c3721761e 100644 --- a/crates/nu-command/src/formats/to/text.rs +++ b/crates/nu-command/src/formats/to/text.rs @@ -1,10 +1,6 @@ use chrono_humanize::HumanTime; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - format_duration, format_filesize_from_conf, Category, Config, Example, IntoPipelineData, - ListStream, PipelineData, RawStream, ShellError, Signature, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::{format_duration, format_filesize_from_conf, Config, ListStream, RawStream}; #[derive(Clone)] pub struct ToText; diff --git a/crates/nu-command/src/formats/to/toml.rs b/crates/nu-command/src/formats/to/toml.rs index d3ec8c800498..aae5fc8b28a4 100644 --- a/crates/nu-command/src/formats/to/toml.rs +++ b/crates/nu-command/src/formats/to/toml.rs @@ -1,9 +1,6 @@ use chrono::SecondsFormat; -use nu_protocol::ast::{Call, PathMember}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::ast::PathMember; #[derive(Clone)] pub struct ToToml; diff --git a/crates/nu-command/src/formats/to/tsv.rs b/crates/nu-command/src/formats/to/tsv.rs index 39bc2e4c69ea..2bed2935d99c 100644 --- a/crates/nu-command/src/formats/to/tsv.rs +++ b/crates/nu-command/src/formats/to/tsv.rs @@ -1,10 +1,6 @@ use crate::formats::to::delimited::to_delimited_data; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Config, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::Config; #[derive(Clone)] pub struct ToTsv; diff --git a/crates/nu-command/src/formats/to/xml.rs b/crates/nu-command/src/formats/to/xml.rs index 1d4e0bf702f0..a550b7c1c069 100644 --- a/crates/nu-command/src/formats/to/xml.rs +++ b/crates/nu-command/src/formats/to/xml.rs @@ -1,16 +1,12 @@ use crate::formats::nu_xml_format::{COLUMN_ATTRS_NAME, COLUMN_CONTENT_NAME, COLUMN_TAG_NAME}; use indexmap::IndexMap; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, Record, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, +use nu_engine::command_prelude::*; + +use quick_xml::{ + escape, + events::{BytesEnd, BytesStart, BytesText, Event}, }; -use quick_xml::escape; -use quick_xml::events::{BytesEnd, BytesStart, BytesText, Event}; -use std::borrow::Cow; -use std::io::Cursor; +use std::{borrow::Cow, io::Cursor}; #[derive(Clone)] pub struct ToXml; diff --git a/crates/nu-command/src/formats/to/yaml.rs b/crates/nu-command/src/formats/to/yaml.rs index 9960c5b34f50..337b4de92b32 100644 --- a/crates/nu-command/src/formats/to/yaml.rs +++ b/crates/nu-command/src/formats/to/yaml.rs @@ -1,8 +1,5 @@ -use nu_protocol::ast::{Call, PathMember}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::ast::PathMember; #[derive(Clone)] pub struct ToYaml; diff --git a/crates/nu-command/src/generators/cal.rs b/crates/nu-command/src/generators/cal.rs index 5d7c3f8b1550..66b7bb3ae149 100644 --- a/crates/nu-command/src/generators/cal.rs +++ b/crates/nu-command/src/generators/cal.rs @@ -1,13 +1,8 @@ use chrono::{Datelike, Local, NaiveDate}; use indexmap::IndexMap; use nu_color_config::StyleComputer; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use std::collections::VecDeque; #[derive(Clone)] diff --git a/crates/nu-command/src/generators/generate.rs b/crates/nu-command/src/generators/generate.rs index c0ab554115d8..e8a36e6ab28c 100644 --- a/crates/nu-command/src/generators/generate.rs +++ b/crates/nu-command/src/generators/generate.rs @@ -1,12 +1,6 @@ use itertools::unfold; -use nu_engine::{get_eval_block_with_early_return, CallExt}; - -use nu_protocol::{ - ast::Call, - engine::{Closure, Command, EngineState, Stack}, - Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, - Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_eval_block_with_early_return}; +use nu_protocol::engine::Closure; #[derive(Clone)] pub struct Generate; diff --git a/crates/nu-command/src/generators/seq.rs b/crates/nu-command/src/generators/seq.rs index 613c5630e15a..f43454b69179 100644 --- a/crates/nu-command/src/generators/seq.rs +++ b/crates/nu-command/src/generators/seq.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, - Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Seq; diff --git a/crates/nu-command/src/generators/seq_char.rs b/crates/nu-command/src/generators/seq_char.rs index 4489c5c6b5a7..2b297b53a076 100644 --- a/crates/nu-command/src/generators/seq_char.rs +++ b/crates/nu-command/src/generators/seq_char.rs @@ -1,9 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - ast::Call, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SeqChar; diff --git a/crates/nu-command/src/generators/seq_date.rs b/crates/nu-command/src/generators/seq_date.rs index b58fde6db859..c583feae9419 100644 --- a/crates/nu-command/src/generators/seq_date.rs +++ b/crates/nu-command/src/generators/seq_date.rs @@ -1,12 +1,6 @@ -use chrono::naive::NaiveDate; -use chrono::{Duration, Local}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, -}; +use chrono::{Duration, Local, NaiveDate}; +use nu_engine::command_prelude::*; + use std::fmt::Write; #[derive(Clone)] diff --git a/crates/nu-command/src/hash/generic_digest.rs b/crates/nu-command/src/hash/generic_digest.rs index a5158c498732..d262a4ca73f8 100644 --- a/crates/nu-command/src/hash/generic_digest.rs +++ b/crates/nu-command/src/hash/generic_digest.rs @@ -1,11 +1,6 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; -use nu_protocol::{IntoPipelineData, Span}; +use nu_engine::command_prelude::*; + use std::marker::PhantomData; pub trait HashDigest: digest::Digest + Clone { diff --git a/crates/nu-command/src/hash/hash_.rs b/crates/nu-command/src/hash/hash_.rs index 0c56668eaa0c..e3b19624a240 100644 --- a/crates/nu-command/src/hash/hash_.rs +++ b/crates/nu-command/src/hash/hash_.rs @@ -1,7 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Hash; diff --git a/crates/nu-command/src/help/help_.rs b/crates/nu-command/src/help/help_.rs index b76f332e1ae4..594504fd4236 100644 --- a/crates/nu-command/src/help/help_.rs +++ b/crates/nu-command/src/help/help_.rs @@ -1,16 +1,10 @@ -use crate::help::help_aliases; -use crate::help::help_commands; -use crate::help::help_modules; +use crate::help::{help_aliases, help_commands, help_modules}; use fancy_regex::Regex; use nu_ansi_term::Style; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - span, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::span; use nu_utils::IgnoreCaseExt; + #[derive(Clone)] pub struct Help; diff --git a/crates/nu-command/src/help/help_aliases.rs b/crates/nu-command/src/help/help_aliases.rs index cc91f3136ae0..ccd1f9d7e238 100644 --- a/crates/nu-command/src/help/help_aliases.rs +++ b/crates/nu-command/src/help/help_aliases.rs @@ -1,12 +1,7 @@ use crate::help::highlight_search_in_table; use nu_color_config::StyleComputer; -use nu_engine::{scope::ScopeData, CallExt}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - span, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, scope::ScopeData}; +use nu_protocol::span; #[derive(Clone)] pub struct HelpAliases; diff --git a/crates/nu-command/src/help/help_commands.rs b/crates/nu-command/src/help/help_commands.rs index 262b0056153f..79ae5ce49bfa 100644 --- a/crates/nu-command/src/help/help_commands.rs +++ b/crates/nu-command/src/help/help_commands.rs @@ -1,12 +1,7 @@ use crate::help::highlight_search_in_table; use nu_color_config::StyleComputer; -use nu_engine::{get_full_help, CallExt}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, span, Category, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; +use nu_protocol::span; #[derive(Clone)] pub struct HelpCommands; diff --git a/crates/nu-command/src/help/help_escapes.rs b/crates/nu-command/src/help/help_escapes.rs index 5401ac1bac45..fe0792c4bc1c 100644 --- a/crates/nu-command/src/help/help_escapes.rs +++ b/crates/nu-command/src/help/help_escapes.rs @@ -1,9 +1,4 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Type, - Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct HelpEscapes; diff --git a/crates/nu-command/src/help/help_externs.rs b/crates/nu-command/src/help/help_externs.rs index 537f5618b7cb..8f42d819485d 100644 --- a/crates/nu-command/src/help/help_externs.rs +++ b/crates/nu-command/src/help/help_externs.rs @@ -1,12 +1,7 @@ use crate::help::highlight_search_in_table; use nu_color_config::StyleComputer; -use nu_engine::{get_full_help, scope::ScopeData, CallExt}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - span, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help, scope::ScopeData}; +use nu_protocol::span; #[derive(Clone)] pub struct HelpExterns; diff --git a/crates/nu-command/src/help/help_modules.rs b/crates/nu-command/src/help/help_modules.rs index e06b8f4bb964..26e65d6ba3e4 100644 --- a/crates/nu-command/src/help/help_modules.rs +++ b/crates/nu-command/src/help/help_modules.rs @@ -1,12 +1,7 @@ use crate::help::highlight_search_in_table; use nu_color_config::StyleComputer; -use nu_engine::{scope::ScopeData, CallExt}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - span, Category, DeclId, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, scope::ScopeData}; +use nu_protocol::{span, DeclId}; #[derive(Clone)] pub struct HelpModules; diff --git a/crates/nu-command/src/help/help_operators.rs b/crates/nu-command/src/help/help_operators.rs index adea7bff5794..b7286b9f4908 100644 --- a/crates/nu-command/src/help/help_operators.rs +++ b/crates/nu-command/src/help/help_operators.rs @@ -1,9 +1,4 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Type, - Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct HelpOperators; diff --git a/crates/nu-command/src/math/abs.rs b/crates/nu-command/src/math/abs.rs index 14e3cc3e941b..8f653142fa7f 100644 --- a/crates/nu-command/src/math/abs.rs +++ b/crates/nu-command/src/math/abs.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/math/avg.rs b/crates/nu-command/src/math/avg.rs index 09c841ef5792..826e9334b264 100644 --- a/crates/nu-command/src/math/avg.rs +++ b/crates/nu-command/src/math/avg.rs @@ -1,10 +1,8 @@ -use crate::math::reducers::{reducer_for, Reduce}; -use crate::math::utils::run_with_function; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, +use crate::math::{ + reducers::{reducer_for, Reduce}, + utils::run_with_function, }; +use nu_engine::command_prelude::*; const NS_PER_SEC: i64 = 1_000_000_000; #[derive(Clone)] diff --git a/crates/nu-command/src/math/ceil.rs b/crates/nu-command/src/math/ceil.rs index d2487dddf67c..0b0f6d1696f3 100644 --- a/crates/nu-command/src/math/ceil.rs +++ b/crates/nu-command/src/math/ceil.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/math/floor.rs b/crates/nu-command/src/math/floor.rs index 14d8d7bdb3c8..e85e3ca67476 100644 --- a/crates/nu-command/src/math/floor.rs +++ b/crates/nu-command/src/math/floor.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/math/log.rs b/crates/nu-command/src/math/log.rs index d8ae79540391..90fad17daf4f 100644 --- a/crates/nu-command/src/math/log.rs +++ b/crates/nu-command/src/math/log.rs @@ -1,9 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/math/math_.rs b/crates/nu-command/src/math/math_.rs index c861ab82bcf4..a4a146738ff5 100644 --- a/crates/nu-command/src/math/math_.rs +++ b/crates/nu-command/src/math/math_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct MathCommand; diff --git a/crates/nu-command/src/math/max.rs b/crates/nu-command/src/math/max.rs index 0add815279c6..86932cb69929 100644 --- a/crates/nu-command/src/math/max.rs +++ b/crates/nu-command/src/math/max.rs @@ -1,10 +1,8 @@ -use crate::math::reducers::{reducer_for, Reduce}; -use crate::math::utils::run_with_function; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, +use crate::math::{ + reducers::{reducer_for, Reduce}, + utils::run_with_function, }; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/math/median.rs b/crates/nu-command/src/math/median.rs index b1e2286eeb27..c95f76408248 100644 --- a/crates/nu-command/src/math/median.rs +++ b/crates/nu-command/src/math/median.rs @@ -1,13 +1,7 @@ +use crate::math::{avg::average, utils::run_with_function}; +use nu_engine::command_prelude::*; use std::cmp::Ordering; -use crate::math::avg::average; -use crate::math::utils::run_with_function; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; - #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/math/min.rs b/crates/nu-command/src/math/min.rs index f8ad69f6b113..3cd922cbc6ab 100644 --- a/crates/nu-command/src/math/min.rs +++ b/crates/nu-command/src/math/min.rs @@ -1,10 +1,8 @@ -use crate::math::reducers::{reducer_for, Reduce}; -use crate::math::utils::run_with_function; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, +use crate::math::{ + reducers::{reducer_for, Reduce}, + utils::run_with_function, }; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/math/mode.rs b/crates/nu-command/src/math/mode.rs index 8a8f4597e870..3c1dc0d8c998 100644 --- a/crates/nu-command/src/math/mode.rs +++ b/crates/nu-command/src/math/mode.rs @@ -1,11 +1,6 @@ use crate::math::utils::run_with_function; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; -use std::cmp::Ordering; -use std::collections::HashMap; +use nu_engine::command_prelude::*; +use std::{cmp::Ordering, collections::HashMap}; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/math/product.rs b/crates/nu-command/src/math/product.rs index 9408f400f522..d88160a8716f 100644 --- a/crates/nu-command/src/math/product.rs +++ b/crates/nu-command/src/math/product.rs @@ -1,10 +1,8 @@ -use crate::math::reducers::{reducer_for, Reduce}; -use crate::math::utils::run_with_function; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, +use crate::math::{ + reducers::{reducer_for, Reduce}, + utils::run_with_function, }; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/math/round.rs b/crates/nu-command/src/math/round.rs index a86816c4843c..7693c9a316d0 100644 --- a/crates/nu-command/src/math/round.rs +++ b/crates/nu-command/src/math/round.rs @@ -1,9 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/math/sqrt.rs b/crates/nu-command/src/math/sqrt.rs index 95427c3b32eb..c9c976591229 100644 --- a/crates/nu-command/src/math/sqrt.rs +++ b/crates/nu-command/src/math/sqrt.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/math/stddev.rs b/crates/nu-command/src/math/stddev.rs index 1f6b04ec1a48..a5d7482915bf 100644 --- a/crates/nu-command/src/math/stddev.rs +++ b/crates/nu-command/src/math/stddev.rs @@ -1,11 +1,6 @@ use super::variance::compute_variance as variance; use crate::math::utils::run_with_function; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/math/sum.rs b/crates/nu-command/src/math/sum.rs index fffe7ee5e9c8..a324d57a2a30 100644 --- a/crates/nu-command/src/math/sum.rs +++ b/crates/nu-command/src/math/sum.rs @@ -1,10 +1,8 @@ -use crate::math::reducers::{reducer_for, Reduce}; -use crate::math::utils::run_with_function; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, +use crate::math::{ + reducers::{reducer_for, Reduce}, + utils::run_with_function, }; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/math/utils.rs b/crates/nu-command/src/math/utils.rs index b6b20b25789a..37c4bd1c0e31 100644 --- a/crates/nu-command/src/math/utils.rs +++ b/crates/nu-command/src/math/utils.rs @@ -1,8 +1,6 @@ use core::slice; - -use indexmap::map::IndexMap; -use nu_protocol::ast::Call; -use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Span, Value}; +use indexmap::IndexMap; +use nu_protocol::{ast::Call, IntoPipelineData, PipelineData, ShellError, Span, Value}; pub fn run_with_function( call: &Call, diff --git a/crates/nu-command/src/math/variance.rs b/crates/nu-command/src/math/variance.rs index 728d3a1474c5..6777aec0fa19 100644 --- a/crates/nu-command/src/math/variance.rs +++ b/crates/nu-command/src/math/variance.rs @@ -1,10 +1,5 @@ use crate::math::utils::run_with_function; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/misc/panic.rs b/crates/nu-command/src/misc/panic.rs index 16294561d347..a24809670b6c 100644 --- a/crates/nu-command/src/misc/panic.rs +++ b/crates/nu-command/src/misc/panic.rs @@ -1,7 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Panic; diff --git a/crates/nu-command/src/misc/source.rs b/crates/nu-command/src/misc/source.rs index 73933b6253ba..798b321c6be2 100644 --- a/crates/nu-command/src/misc/source.rs +++ b/crates/nu-command/src/misc/source.rs @@ -1,8 +1,4 @@ -use nu_engine::{get_eval_block_with_early_return, CallExt}; -use nu_protocol::ast::Call; - -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type}; +use nu_engine::{command_prelude::*, get_eval_block_with_early_return}; /// Source a file for environment variables. #[derive(Clone)] diff --git a/crates/nu-command/src/misc/tutor.rs b/crates/nu-command/src/misc/tutor.rs index f633a6751c85..8eeec6f393b6 100644 --- a/crates/nu-command/src/misc/tutor.rs +++ b/crates/nu-command/src/misc/tutor.rs @@ -1,11 +1,5 @@ use itertools::Itertools; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Tutor; diff --git a/crates/nu-command/src/network/http/client.rs b/crates/nu-command/src/network/http/client.rs index caa72edb5ee1..61ada986c75a 100644 --- a/crates/nu-command/src/network/http/client.rs +++ b/crates/nu-command/src/network/http/client.rs @@ -1,23 +1,24 @@ use crate::formats::value_to_json_value; -use base64::engine::general_purpose::PAD; -use base64::engine::GeneralPurpose; -use base64::{alphabet, Engine}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{EngineState, Stack}; -use nu_protocol::{ - record, BufferedReader, IntoPipelineData, PipelineData, RawStream, ShellError, Span, Spanned, - Value, +use base64::{ + alphabet, + engine::{general_purpose::PAD, GeneralPurpose}, + Engine, +}; +use nu_engine::command_prelude::*; +use nu_protocol::{BufferedReader, RawStream}; +use std::{ + collections::HashMap, + io::BufReader, + path::PathBuf, + str::FromStr, + sync::{ + atomic::AtomicBool, + mpsc::{self, RecvTimeoutError}, + Arc, + }, + time::Duration, }; use ureq::{Error, ErrorKind, Request, Response}; - -use std::collections::HashMap; -use std::io::BufReader; -use std::path::PathBuf; -use std::str::FromStr; -use std::sync::atomic::AtomicBool; -use std::sync::mpsc::{self, RecvTimeoutError}; -use std::sync::Arc; -use std::time::Duration; use url::Url; #[derive(PartialEq, Eq)] diff --git a/crates/nu-command/src/network/http/delete.rs b/crates/nu-command/src/network/http/delete.rs index 7a31c7c43267..77cfa70fb854 100644 --- a/crates/nu-command/src/network/http/delete.rs +++ b/crates/nu-command/src/network/http/delete.rs @@ -1,17 +1,9 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; - use crate::network::http::client::{ check_response_redirection, http_client, http_parse_redirect_mode, http_parse_url, request_add_authorization_header, request_add_custom_headers, request_handle_response, - request_set_timeout, send_request, + request_set_timeout, send_request, RequestFlags, }; - -use super::client::RequestFlags; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/network/http/get.rs b/crates/nu-command/src/network/http/get.rs index 72dfb05db870..e86c44e0a192 100644 --- a/crates/nu-command/src/network/http/get.rs +++ b/crates/nu-command/src/network/http/get.rs @@ -1,15 +1,9 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; - use crate::network::http::client::{ check_response_redirection, http_client, http_parse_redirect_mode, http_parse_url, request_add_authorization_header, request_add_custom_headers, request_handle_response, request_set_timeout, send_request, RequestFlags, }; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/network/http/head.rs b/crates/nu-command/src/network/http/head.rs index 2a097dab33ba..875cdc8d8e15 100644 --- a/crates/nu-command/src/network/http/head.rs +++ b/crates/nu-command/src/network/http/head.rs @@ -1,18 +1,11 @@ -use std::sync::atomic::AtomicBool; -use std::sync::Arc; - -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; - use crate::network::http::client::{ check_response_redirection, http_client, http_parse_redirect_mode, http_parse_url, request_add_authorization_header, request_add_custom_headers, request_handle_response_headers, request_set_timeout, send_request, }; +use nu_engine::command_prelude::*; + +use std::sync::{atomic::AtomicBool, Arc}; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/network/http/http_.rs b/crates/nu-command/src/network/http/http_.rs index dc4fced117d9..15bc96494c2c 100644 --- a/crates/nu-command/src/network/http/http_.rs +++ b/crates/nu-command/src/network/http/http_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Http; diff --git a/crates/nu-command/src/network/http/options.rs b/crates/nu-command/src/network/http/options.rs index 2b456d2bb9c1..fe4b7dcb1a58 100644 --- a/crates/nu-command/src/network/http/options.rs +++ b/crates/nu-command/src/network/http/options.rs @@ -1,16 +1,8 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; - use crate::network::http::client::{ http_client, http_parse_url, request_add_authorization_header, request_add_custom_headers, - request_handle_response, request_set_timeout, send_request, + request_handle_response, request_set_timeout, send_request, RedirectMode, RequestFlags, }; - -use super::client::{RedirectMode, RequestFlags}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/network/http/patch.rs b/crates/nu-command/src/network/http/patch.rs index fd8cbd3cea33..ca302702eff9 100644 --- a/crates/nu-command/src/network/http/patch.rs +++ b/crates/nu-command/src/network/http/patch.rs @@ -1,17 +1,9 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; - use crate::network::http::client::{ check_response_redirection, http_client, http_parse_redirect_mode, http_parse_url, request_add_authorization_header, request_add_custom_headers, request_handle_response, - request_set_timeout, send_request, + request_set_timeout, send_request, RequestFlags, }; - -use super::client::RequestFlags; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/network/http/post.rs b/crates/nu-command/src/network/http/post.rs index aac53f8d27a2..1f0d7f81b0c2 100644 --- a/crates/nu-command/src/network/http/post.rs +++ b/crates/nu-command/src/network/http/post.rs @@ -1,17 +1,9 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; - use crate::network::http::client::{ check_response_redirection, http_client, http_parse_redirect_mode, http_parse_url, request_add_authorization_header, request_add_custom_headers, request_handle_response, - request_set_timeout, send_request, + request_set_timeout, send_request, RequestFlags, }; - -use super::client::RequestFlags; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/network/http/put.rs b/crates/nu-command/src/network/http/put.rs index 58f04ba16986..8abedd2b4c84 100644 --- a/crates/nu-command/src/network/http/put.rs +++ b/crates/nu-command/src/network/http/put.rs @@ -1,17 +1,9 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; - use crate::network::http::client::{ check_response_redirection, http_client, http_parse_redirect_mode, http_parse_url, request_add_authorization_header, request_add_custom_headers, request_handle_response, - request_set_timeout, send_request, + request_set_timeout, send_request, RequestFlags, }; - -use super::client::RequestFlags; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/network/port.rs b/crates/nu-command/src/network/port.rs index ce712bbd9e0d..746df62d3a1f 100644 --- a/crates/nu-command/src/network/port.rs +++ b/crates/nu-command/src/network/port.rs @@ -1,12 +1,6 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoPipelineData, Span, Spanned}; -use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpListener}; +use nu_engine::command_prelude::*; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpListener}; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/network/url/build_query.rs b/crates/nu-command/src/network/url/build_query.rs index 556b161a8dde..92b5057b6082 100644 --- a/crates/nu-command/src/network/url/build_query.rs +++ b/crates/nu-command/src/network/url/build_query.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/network/url/decode.rs b/crates/nu-command/src/network/url/decode.rs index c1179d328a71..1d95dba36e07 100644 --- a/crates/nu-command/src/network/url/decode.rs +++ b/crates/nu-command/src/network/url/decode.rs @@ -1,9 +1,6 @@ use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs}; -use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; + use percent_encoding::percent_decode_str; #[derive(Clone)] diff --git a/crates/nu-command/src/network/url/encode.rs b/crates/nu-command/src/network/url/encode.rs index 82cd4fa3e2ae..067350022849 100644 --- a/crates/nu-command/src/network/url/encode.rs +++ b/crates/nu-command/src/network/url/encode.rs @@ -1,10 +1,6 @@ use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; + use percent_encoding::{utf8_percent_encode, AsciiSet, NON_ALPHANUMERIC}; #[derive(Clone)] diff --git a/crates/nu-command/src/network/url/join.rs b/crates/nu-command/src/network/url/join.rs index 52668d1a0977..4d73bcb00f92 100644 --- a/crates/nu-command/src/network/url/join.rs +++ b/crates/nu-command/src/network/url/join.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/network/url/mod.rs b/crates/nu-command/src/network/url/mod.rs index 7cdb5ad4e4da..2ca22e128c45 100644 --- a/crates/nu-command/src/network/url/mod.rs +++ b/crates/nu-command/src/network/url/mod.rs @@ -5,8 +5,6 @@ mod join; mod parse; mod url_; -use url::{self}; - pub use self::parse::SubCommand as UrlParse; pub use build_query::SubCommand as UrlBuildQuery; pub use decode::SubCommand as UrlDecode; diff --git a/crates/nu-command/src/network/url/parse.rs b/crates/nu-command/src/network/url/parse.rs index 1d54a0895733..f3b811e45d1d 100644 --- a/crates/nu-command/src/network/url/parse.rs +++ b/crates/nu-command/src/network/url/parse.rs @@ -1,10 +1,4 @@ -use super::url; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; - +use nu_engine::command_prelude::*; use url::Url; #[derive(Clone)] diff --git a/crates/nu-command/src/network/url/url_.rs b/crates/nu-command/src/network/url/url_.rs index 078588913356..9f795c7eabab 100644 --- a/crates/nu-command/src/network/url/url_.rs +++ b/crates/nu-command/src/network/url/url_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Url; diff --git a/crates/nu-command/src/path/basename.rs b/crates/nu-command/src/path/basename.rs index 58b7a50eb1a3..04f7cf380e7d 100644 --- a/crates/nu-command/src/path/basename.rs +++ b/crates/nu-command/src/path/basename.rs @@ -1,13 +1,7 @@ -use std::path::Path; - use super::PathSubcommandArguments; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::{ - engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::engine::StateWorkingSet; +use std::path::Path; struct Arguments { replace: Option>, diff --git a/crates/nu-command/src/path/dirname.rs b/crates/nu-command/src/path/dirname.rs index 39cf79539443..2eb864215ed0 100644 --- a/crates/nu-command/src/path/dirname.rs +++ b/crates/nu-command/src/path/dirname.rs @@ -1,14 +1,7 @@ -use std::path::Path; - -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::{ - engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, -}; - use super::PathSubcommandArguments; +use nu_engine::command_prelude::*; +use nu_protocol::engine::StateWorkingSet; +use std::path::Path; struct Arguments { replace: Option>, diff --git a/crates/nu-command/src/path/exists.rs b/crates/nu-command/src/path/exists.rs index b6764db141ad..a90a2b5c9100 100644 --- a/crates/nu-command/src/path/exists.rs +++ b/crates/nu-command/src/path/exists.rs @@ -1,14 +1,8 @@ -use std::path::{Path, PathBuf}; - -use nu_engine::{current_dir, current_dir_const, CallExt}; -use nu_path::expand_path_with; -use nu_protocol::ast::Call; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::{ - engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; - use super::PathSubcommandArguments; +use nu_engine::{command_prelude::*, current_dir, current_dir_const}; +use nu_path::expand_path_with; +use nu_protocol::engine::StateWorkingSet; +use std::path::{Path, PathBuf}; struct Arguments { pwd: PathBuf, diff --git a/crates/nu-command/src/path/expand.rs b/crates/nu-command/src/path/expand.rs index 9a6fc1145b94..53e2e1c4e8d2 100644 --- a/crates/nu-command/src/path/expand.rs +++ b/crates/nu-command/src/path/expand.rs @@ -1,15 +1,11 @@ -use std::path::Path; - -use nu_engine::env::{current_dir_str, current_dir_str_const}; -use nu_engine::CallExt; -use nu_path::{canonicalize_with, expand_path_with}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::{ - engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; - use super::PathSubcommandArguments; +use nu_engine::{ + command_prelude::*, + env::{current_dir_str, current_dir_str_const}, +}; +use nu_path::{canonicalize_with, expand_path_with}; +use nu_protocol::engine::StateWorkingSet; +use std::path::Path; struct Arguments { strict: bool, diff --git a/crates/nu-command/src/path/join.rs b/crates/nu-command/src/path/join.rs index e6df2461db69..fc424a7f0ef7 100644 --- a/crates/nu-command/src/path/join.rs +++ b/crates/nu-command/src/path/join.rs @@ -1,14 +1,7 @@ -use std::path::{Path, PathBuf}; - -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::{ - engine::Command, Category, Example, PipelineData, Record, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, -}; - use super::PathSubcommandArguments; +use nu_engine::command_prelude::*; +use nu_protocol::engine::StateWorkingSet; +use std::path::{Path, PathBuf}; struct Arguments { append: Vec>, diff --git a/crates/nu-command/src/path/mod.rs b/crates/nu-command/src/path/mod.rs index 893f644752a2..8a7b9a6f2cea 100644 --- a/crates/nu-command/src/path/mod.rs +++ b/crates/nu-command/src/path/mod.rs @@ -9,8 +9,6 @@ mod relative_to; mod split; mod r#type; -use std::path::Path as StdPath; - pub use basename::SubCommand as PathBasename; pub use dirname::SubCommand as PathDirname; pub use exists::SubCommand as PathExists; @@ -23,6 +21,7 @@ pub use relative_to::SubCommand as PathRelativeTo; pub use split::SubCommand as PathSplit; use nu_protocol::{ShellError, Span, Value}; +use std::path::Path as StdPath; #[cfg(windows)] const ALLOWED_COLUMNS: [&str; 4] = ["prefix", "parent", "stem", "extension"]; diff --git a/crates/nu-command/src/path/parse.rs b/crates/nu-command/src/path/parse.rs index 3435d48142fc..e1cebb2ec34f 100644 --- a/crates/nu-command/src/path/parse.rs +++ b/crates/nu-command/src/path/parse.rs @@ -1,14 +1,7 @@ -use std::path::Path; - -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::{ - engine::Command, Category, Example, PipelineData, Record, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, -}; - use super::PathSubcommandArguments; +use nu_engine::command_prelude::*; +use nu_protocol::engine::StateWorkingSet; +use std::path::Path; struct Arguments { extension: Option>, @@ -97,8 +90,6 @@ On Windows, an extra 'prefix' column is added."# #[cfg(windows)] fn examples(&self) -> Vec { - use nu_protocol::record; - vec![ Example { description: "Parse a single path", @@ -148,8 +139,6 @@ On Windows, an extra 'prefix' column is added."# #[cfg(not(windows))] fn examples(&self) -> Vec { - use nu_protocol::record; - vec![ Example { description: "Parse a path", diff --git a/crates/nu-command/src/path/path_.rs b/crates/nu-command/src/path/path_.rs index 5ce036b81f9e..19351d590a40 100644 --- a/crates/nu-command/src/path/path_.rs +++ b/crates/nu-command/src/path/path_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct PathCommand; diff --git a/crates/nu-command/src/path/relative_to.rs b/crates/nu-command/src/path/relative_to.rs index bc11b8cd6be5..6533f6fa790e 100644 --- a/crates/nu-command/src/path/relative_to.rs +++ b/crates/nu-command/src/path/relative_to.rs @@ -1,15 +1,8 @@ -use std::path::Path; - -use nu_engine::CallExt; -use nu_path::expand_to_real_path; -use nu_protocol::ast::Call; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::{ - engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, -}; - use super::PathSubcommandArguments; +use nu_engine::command_prelude::*; +use nu_path::expand_to_real_path; +use nu_protocol::engine::StateWorkingSet; +use std::path::Path; struct Arguments { path: Spanned, diff --git a/crates/nu-command/src/path/split.rs b/crates/nu-command/src/path/split.rs index 1c67f69f4c0e..ea8e7e1b1fbf 100644 --- a/crates/nu-command/src/path/split.rs +++ b/crates/nu-command/src/path/split.rs @@ -1,12 +1,7 @@ -use std::path::{Component, Path}; - -use nu_protocol::ast::Call; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::{ - engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; - use super::PathSubcommandArguments; +use nu_engine::command_prelude::*; +use nu_protocol::engine::StateWorkingSet; +use std::path::{Component, Path}; struct Arguments; diff --git a/crates/nu-command/src/path/type.rs b/crates/nu-command/src/path/type.rs index 39d6ebb0654c..8fbc270445e6 100644 --- a/crates/nu-command/src/path/type.rs +++ b/crates/nu-command/src/path/type.rs @@ -1,13 +1,8 @@ -use std::path::Path; - -use nu_path::expand_tilde; -use nu_protocol::ast::Call; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::{ - engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; - use super::PathSubcommandArguments; +use nu_engine::command_prelude::*; +use nu_path::expand_tilde; +use nu_protocol::engine::StateWorkingSet; +use std::path::Path; struct Arguments; diff --git a/crates/nu-command/src/platform/ansi/ansi_.rs b/crates/nu-command/src/platform/ansi/ansi_.rs index 219e129ce113..e4f2bca3787f 100644 --- a/crates/nu-command/src/platform/ansi/ansi_.rs +++ b/crates/nu-command/src/platform/ansi/ansi_.rs @@ -1,16 +1,11 @@ use nu_ansi_term::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::Command, - engine::StateWorkingSet, - engine::{EngineState, Stack}, - record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::engine::StateWorkingSet; use once_cell::sync::Lazy; -use std::collections::HashMap; -use std::sync::{atomic::AtomicBool, Arc}; +use std::{ + collections::HashMap, + sync::{atomic::AtomicBool, Arc}, +}; #[derive(Clone)] pub struct AnsiCommand; diff --git a/crates/nu-command/src/platform/ansi/link.rs b/crates/nu-command/src/platform/ansi/link.rs index ce5b2e4bb542..f6423ff0ec68 100644 --- a/crates/nu-command/src/platform/ansi/link.rs +++ b/crates/nu-command/src/platform/ansi/link.rs @@ -1,12 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::Command, - engine::EngineState, - engine::Stack, - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, - Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/platform/ansi/strip.rs b/crates/nu-command/src/platform/ansi/strip.rs index 71d48fc5a6cc..ee64a3ebc13a 100644 --- a/crates/nu-command/src/platform/ansi/strip.rs +++ b/crates/nu-command/src/platform/ansi/strip.rs @@ -1,10 +1,6 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - Category, Config, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::Config; pub struct Arguments { cell_paths: Option>, diff --git a/crates/nu-command/src/platform/clear.rs b/crates/nu-command/src/platform/clear.rs index 507824b430db..7dbe79bd2227 100644 --- a/crates/nu-command/src/platform/clear.rs +++ b/crates/nu-command/src/platform/clear.rs @@ -3,10 +3,8 @@ use crossterm::{ terminal::{Clear as ClearCommand, ClearType}, QueueableCommand, }; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Type}; +use nu_engine::command_prelude::*; + use std::io::Write; #[derive(Clone)] diff --git a/crates/nu-command/src/platform/dir_info.rs b/crates/nu-command/src/platform/dir_info.rs index 3baa7138fcff..e4a30396724f 100644 --- a/crates/nu-command/src/platform/dir_info.rs +++ b/crates/nu-command/src/platform/dir_info.rs @@ -1,9 +1,10 @@ use filesize::file_real_size_fast; use nu_glob::Pattern; use nu_protocol::{record, ShellError, Span, Value}; -use std::path::PathBuf; -use std::sync::atomic::AtomicBool; -use std::sync::Arc; +use std::{ + path::PathBuf, + sync::{atomic::AtomicBool, Arc}, +}; #[derive(Debug, Clone)] pub struct DirBuilder { diff --git a/crates/nu-command/src/platform/input/input_.rs b/crates/nu-command/src/platform/input/input_.rs index 71678f2ac884..b7f074da0da2 100644 --- a/crates/nu-command/src/platform/input/input_.rs +++ b/crates/nu-command/src/platform/input/input_.rs @@ -6,15 +6,9 @@ use crossterm::{ terminal::{self, ClearType}, }; use itertools::Itertools; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Spanned, SyntaxShape, - Type, Value, -}; -use std::io::Write; -use std::time::Duration; +use nu_engine::command_prelude::*; + +use std::{io::Write, time::Duration}; #[derive(Clone)] pub struct Input; diff --git a/crates/nu-command/src/platform/input/input_listen.rs b/crates/nu-command/src/platform/input/input_listen.rs index 77f9d4fd73e7..25147001373e 100644 --- a/crates/nu-command/src/platform/input/input_listen.rs +++ b/crates/nu-command/src/platform/input/input_listen.rs @@ -3,13 +3,8 @@ use crossterm::event::{ EnableMouseCapture, KeyCode, KeyEventKind, KeyModifiers, MouseEvent, MouseEventKind, }; use crossterm::terminal; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use num_traits::AsPrimitive; use std::io::stdout; diff --git a/crates/nu-command/src/platform/input/list.rs b/crates/nu-command/src/platform/input/list.rs index 598a3914b045..498137bb6795 100644 --- a/crates/nu-command/src/platform/input/list.rs +++ b/crates/nu-command/src/platform/input/list.rs @@ -1,12 +1,6 @@ -use dialoguer::{console::Term, Select}; -use dialoguer::{FuzzySelect, MultiSelect}; -use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, - Value, -}; +use dialoguer::{console::Term, FuzzySelect, MultiSelect, Select}; +use nu_engine::command_prelude::*; + use std::fmt::{Display, Formatter}; enum InteractMode { diff --git a/crates/nu-command/src/platform/is_terminal.rs b/crates/nu-command/src/platform/is_terminal.rs index bdaf7c2cf815..770fa45289de 100644 --- a/crates/nu-command/src/platform/is_terminal.rs +++ b/crates/nu-command/src/platform/is_terminal.rs @@ -1,9 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - span, Category, Example, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::span; use std::io::IsTerminal as _; #[derive(Clone)] diff --git a/crates/nu-command/src/platform/kill.rs b/crates/nu-command/src/platform/kill.rs index 23d491f2ff57..012a6bf13329 100644 --- a/crates/nu-command/src/platform/kill.rs +++ b/crates/nu-command/src/platform/kill.rs @@ -1,10 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ast::Call, span}; -use nu_protocol::{ - Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, - Signature, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::span; use std::process::{Command as CommandSys, Stdio}; #[derive(Clone)] diff --git a/crates/nu-command/src/platform/sleep.rs b/crates/nu-command/src/platform/sleep.rs index e708998b9b58..ddf429509c8e 100644 --- a/crates/nu-command/src/platform/sleep.rs +++ b/crates/nu-command/src/platform/sleep.rs @@ -1,10 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; + use std::{ thread, time::{Duration, Instant}, diff --git a/crates/nu-command/src/platform/term_size.rs b/crates/nu-command/src/platform/term_size.rs index 5cbc8c0637d3..011ff2c7c2a2 100644 --- a/crates/nu-command/src/platform/term_size.rs +++ b/crates/nu-command/src/platform/term_size.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::command_prelude::*; use terminal_size::{terminal_size, Height, Width}; #[derive(Clone)] diff --git a/crates/nu-command/src/platform/ulimit.rs b/crates/nu-command/src/platform/ulimit.rs index 7b5f7fcb0406..6ef2cd2b576a 100644 --- a/crates/nu-command/src/platform/ulimit.rs +++ b/crates/nu-command/src/platform/ulimit.rs @@ -1,11 +1,6 @@ use nix::sys::resource::{rlim_t, Resource, RLIM_INFINITY}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, Record, ShellError, Signature, Span, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use once_cell::sync::Lazy; /// An object contains resource related parameters diff --git a/crates/nu-command/src/platform/whoami.rs b/crates/nu-command/src/platform/whoami.rs index 9cef7aff4771..a1edc1e1848e 100644 --- a/crates/nu-command/src/platform/whoami.rs +++ b/crates/nu-command/src/platform/whoami.rs @@ -1,8 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Whoami; diff --git a/crates/nu-command/src/random/bool.rs b/crates/nu-command/src/random/bool.rs index ddcb2c8dc885..6c78516ed60c 100644 --- a/crates/nu-command/src/random/bool.rs +++ b/crates/nu-command/src/random/bool.rs @@ -1,9 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use rand::prelude::{thread_rng, Rng}; #[derive(Clone)] diff --git a/crates/nu-command/src/random/chars.rs b/crates/nu-command/src/random/chars.rs index c07e7c0cbd3d..fe1e6bcdc4f1 100644 --- a/crates/nu-command/src/random/chars.rs +++ b/crates/nu-command/src/random/chars.rs @@ -1,9 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use rand::{ distributions::{Alphanumeric, Distribution}, thread_rng, diff --git a/crates/nu-command/src/random/dice.rs b/crates/nu-command/src/random/dice.rs index 8ee30658acef..b0569c697ec4 100644 --- a/crates/nu-command/src/random/dice.rs +++ b/crates/nu-command/src/random/dice.rs @@ -1,9 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, ListStream, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::ListStream; use rand::prelude::{thread_rng, Rng}; #[derive(Clone)] diff --git a/crates/nu-command/src/random/float.rs b/crates/nu-command/src/random/float.rs index 8e3bef2002e6..197c85b533dc 100644 --- a/crates/nu-command/src/random/float.rs +++ b/crates/nu-command/src/random/float.rs @@ -1,10 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, Range, ShellError, Signature, Span, Spanned, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::Range; use rand::prelude::{thread_rng, Rng}; use std::cmp::Ordering; diff --git a/crates/nu-command/src/random/int.rs b/crates/nu-command/src/random/int.rs index 7358a9e31d34..f2a1f22a623a 100644 --- a/crates/nu-command/src/random/int.rs +++ b/crates/nu-command/src/random/int.rs @@ -1,10 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, Range, ShellError, Signature, Spanned, SyntaxShape, Type, - Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::Range; use rand::prelude::{thread_rng, Rng}; use std::cmp::Ordering; diff --git a/crates/nu-command/src/random/random_.rs b/crates/nu-command/src/random/random_.rs index 3fe0a9cd7b88..21819fa24f16 100644 --- a/crates/nu-command/src/random/random_.rs +++ b/crates/nu-command/src/random/random_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct RandomCommand; diff --git a/crates/nu-command/src/random/uuid.rs b/crates/nu-command/src/random/uuid.rs index b9186342ac50..c8d8d638b9dd 100644 --- a/crates/nu-command/src/random/uuid.rs +++ b/crates/nu-command/src/random/uuid.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Type, Value}; +use nu_engine::command_prelude::*; use uuid::Uuid; #[derive(Clone)] diff --git a/crates/nu-command/src/removed/format.rs b/crates/nu-command/src/removed/format.rs index 361012aff9ad..fb2b50cd39af 100644 --- a/crates/nu-command/src/removed/format.rs +++ b/crates/nu-command/src/removed/format.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape, Type}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/removed/let_env.rs b/crates/nu-command/src/removed/let_env.rs index 7088dbd10573..a7e3de594c29 100644 --- a/crates/nu-command/src/removed/let_env.rs +++ b/crates/nu-command/src/removed/let_env.rs @@ -1,6 +1,4 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape, Type}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct LetEnv; diff --git a/crates/nu-command/src/shells/exit.rs b/crates/nu-command/src/shells/exit.rs index f1ce71fac884..018c519ef7e8 100644 --- a/crates/nu-command/src/shells/exit.rs +++ b/crates/nu-command/src/shells/exit.rs @@ -1,7 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Exit; diff --git a/crates/nu-command/src/stor/create.rs b/crates/nu-command/src/stor/create.rs index b8ba5e79c476..6c00375766db 100644 --- a/crates/nu-command/src/stor/create.rs +++ b/crates/nu-command/src/stor/create.rs @@ -1,11 +1,5 @@ use crate::database::{SQLiteDatabase, MEMORY_DB}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, Record, ShellError, Signature, Span, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct StorCreate; diff --git a/crates/nu-command/src/stor/delete.rs b/crates/nu-command/src/stor/delete.rs index 242d54c7966a..7de9169ed98b 100644 --- a/crates/nu-command/src/stor/delete.rs +++ b/crates/nu-command/src/stor/delete.rs @@ -1,11 +1,5 @@ use crate::database::{SQLiteDatabase, MEMORY_DB}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct StorDelete; diff --git a/crates/nu-command/src/stor/export.rs b/crates/nu-command/src/stor/export.rs index f91bde774122..ea1a6f12a008 100644 --- a/crates/nu-command/src/stor/export.rs +++ b/crates/nu-command/src/stor/export.rs @@ -1,11 +1,5 @@ use crate::database::{SQLiteDatabase, MEMORY_DB}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct StorExport; diff --git a/crates/nu-command/src/stor/import.rs b/crates/nu-command/src/stor/import.rs index 94b184905eef..f5d7360cb2ce 100644 --- a/crates/nu-command/src/stor/import.rs +++ b/crates/nu-command/src/stor/import.rs @@ -1,11 +1,5 @@ use crate::database::{SQLiteDatabase, MEMORY_DB}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct StorImport; diff --git a/crates/nu-command/src/stor/insert.rs b/crates/nu-command/src/stor/insert.rs index 6fda249334a0..51cc97159027 100644 --- a/crates/nu-command/src/stor/insert.rs +++ b/crates/nu-command/src/stor/insert.rs @@ -1,11 +1,5 @@ use crate::database::{SQLiteDatabase, MEMORY_DB}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, Record, ShellError, Signature, Span, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct StorInsert; diff --git a/crates/nu-command/src/stor/open.rs b/crates/nu-command/src/stor/open.rs index 0888e52e270c..c7f6f9f74659 100644 --- a/crates/nu-command/src/stor/open.rs +++ b/crates/nu-command/src/stor/open.rs @@ -1,9 +1,5 @@ use crate::database::{SQLiteDatabase, MEMORY_DB}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct StorOpen; diff --git a/crates/nu-command/src/stor/reset.rs b/crates/nu-command/src/stor/reset.rs index 97603bf00045..9dfc33e20dbd 100644 --- a/crates/nu-command/src/stor/reset.rs +++ b/crates/nu-command/src/stor/reset.rs @@ -1,9 +1,5 @@ use crate::database::{SQLiteDatabase, MEMORY_DB}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct StorReset; diff --git a/crates/nu-command/src/stor/stor_.rs b/crates/nu-command/src/stor/stor_.rs index a359cb9f0e25..e736fd83576c 100644 --- a/crates/nu-command/src/stor/stor_.rs +++ b/crates/nu-command/src/stor/stor_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Stor; diff --git a/crates/nu-command/src/stor/update.rs b/crates/nu-command/src/stor/update.rs index 15769163f0a9..ae63079d9cdb 100644 --- a/crates/nu-command/src/stor/update.rs +++ b/crates/nu-command/src/stor/update.rs @@ -1,11 +1,5 @@ use crate::database::{SQLiteDatabase, MEMORY_DB}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, Record, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct StorUpdate; diff --git a/crates/nu-command/src/strings/char_.rs b/crates/nu-command/src/strings/char_.rs index 7ab236b629f6..befab1a93d7b 100644 --- a/crates/nu-command/src/strings/char_.rs +++ b/crates/nu-command/src/strings/char_.rs @@ -1,12 +1,6 @@ -use indexmap::indexmap; -use indexmap::map::IndexMap; -use nu_engine::CallExt; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::record; -use nu_protocol::{ - ast::Call, engine::Command, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, - PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use indexmap::{indexmap, IndexMap}; +use nu_engine::command_prelude::*; +use nu_protocol::engine::StateWorkingSet; use once_cell::sync::Lazy; use std::sync::{atomic::AtomicBool, Arc}; diff --git a/crates/nu-command/src/strings/detect_columns.rs b/crates/nu-command/src/strings/detect_columns.rs index 0d87ee187c42..2a9f7d6563c7 100644 --- a/crates/nu-command/src/strings/detect_columns.rs +++ b/crates/nu-command/src/strings/detect_columns.rs @@ -1,16 +1,7 @@ -use nu_protocol::IntoPipelineData; -use std::io::Cursor; -use std::iter::Peekable; -use std::str::CharIndices; - use itertools::Itertools; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, IntoInterruptiblePipelineData, PipelineData, Range, Record, - ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::Range; +use std::{io::Cursor, iter::Peekable, str::CharIndices}; type Input<'t> = Peekable>; diff --git a/crates/nu-command/src/strings/encode_decode/base64.rs b/crates/nu-command/src/strings/encode_decode/base64.rs index 0e9276a4099b..0f91a964660b 100644 --- a/crates/nu-command/src/strings/encode_decode/base64.rs +++ b/crates/nu-command/src/strings/encode_decode/base64.rs @@ -1,12 +1,18 @@ use base64::{ - alphabet, engine::general_purpose::NO_PAD, engine::general_purpose::PAD, - engine::GeneralPurpose, Engine, + alphabet, + engine::{ + general_purpose::{NO_PAD, PAD}, + GeneralPurpose, + }, + Engine, }; use nu_cmd_base::input_handler::{operate as general_operate, CmdArgument}; use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{EngineState, Stack}; -use nu_protocol::{PipelineData, ShellError, Span, Spanned, Value}; +use nu_protocol::{ + ast::{Call, CellPath}, + engine::{EngineState, Stack}, + PipelineData, ShellError, Span, Spanned, Value, +}; pub const CHARACTER_SET_DESC: &str = "specify the character rules for encoding the input.\n\ \tValid values are 'standard', 'standard-no-padding', 'url-safe', 'url-safe-no-padding',\ diff --git a/crates/nu-command/src/strings/encode_decode/decode.rs b/crates/nu-command/src/strings/encode_decode/decode.rs index 38afc4c162ac..25b8f59ec277 100644 --- a/crates/nu-command/src/strings/encode_decode/decode.rs +++ b/crates/nu-command/src/strings/encode_decode/decode.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Decode; diff --git a/crates/nu-command/src/strings/encode_decode/decode_base64.rs b/crates/nu-command/src/strings/encode_decode/decode_base64.rs index f024096fcc33..3a8d17debb4c 100644 --- a/crates/nu-command/src/strings/encode_decode/decode_base64.rs +++ b/crates/nu-command/src/strings/encode_decode/decode_base64.rs @@ -1,9 +1,5 @@ use super::base64::{operate, ActionType, CHARACTER_SET_DESC}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct DecodeBase64; diff --git a/crates/nu-command/src/strings/encode_decode/encode.rs b/crates/nu-command/src/strings/encode_decode/encode.rs index 6e41563339f0..b017da4a8ac9 100644 --- a/crates/nu-command/src/strings/encode_decode/encode.rs +++ b/crates/nu-command/src/strings/encode_decode/encode.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct Encode; diff --git a/crates/nu-command/src/strings/encode_decode/encode_base64.rs b/crates/nu-command/src/strings/encode_decode/encode_base64.rs index 973b6630a6cd..694c3210f37f 100644 --- a/crates/nu-command/src/strings/encode_decode/encode_base64.rs +++ b/crates/nu-command/src/strings/encode_decode/encode_base64.rs @@ -1,9 +1,5 @@ use super::base64::{operate, ActionType, CHARACTER_SET_DESC}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct EncodeBase64; diff --git a/crates/nu-command/src/strings/format/date.rs b/crates/nu-command/src/strings/format/date.rs index 3a00b97184c1..146822aa65a9 100644 --- a/crates/nu-command/src/strings/format/date.rs +++ b/crates/nu-command/src/strings/format/date.rs @@ -1,17 +1,10 @@ +use crate::{generate_strftime_list, parse_date_from_string}; use chrono::{DateTime, Locale, TimeZone}; +use nu_engine::command_prelude::*; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, - Value, -}; use nu_utils::locale::{get_system_locale_string, LOCALE_OVERRIDE_ENV_VAR}; use std::fmt::{Display, Write}; -use crate::{generate_strftime_list, parse_date_from_string}; - #[derive(Clone)] pub struct FormatDate; diff --git a/crates/nu-command/src/strings/format/duration.rs b/crates/nu-command/src/strings/format/duration.rs index 572cc4dcfe64..d95d155978bf 100644 --- a/crates/nu-command/src/strings/format/duration.rs +++ b/crates/nu-command/src/strings/format/duration.rs @@ -1,10 +1,5 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; struct Arguments { format_value: String, diff --git a/crates/nu-command/src/strings/format/filesize.rs b/crates/nu-command/src/strings/format/filesize.rs index c5bf99516b9d..97a9cad4daa5 100644 --- a/crates/nu-command/src/strings/format/filesize.rs +++ b/crates/nu-command/src/strings/format/filesize.rs @@ -1,11 +1,6 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - format_filesize, Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::format_filesize; struct Arguments { format_value: String, diff --git a/crates/nu-command/src/strings/format/format_.rs b/crates/nu-command/src/strings/format/format_.rs index ac348d12eaa4..18159b610f1e 100644 --- a/crates/nu-command/src/strings/format/format_.rs +++ b/crates/nu-command/src/strings/format/format_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Format; diff --git a/crates/nu-command/src/strings/mod.rs b/crates/nu-command/src/strings/mod.rs index d99d720b54ee..d1ebf540e51d 100644 --- a/crates/nu-command/src/strings/mod.rs +++ b/crates/nu-command/src/strings/mod.rs @@ -11,11 +11,11 @@ pub use char_::Char; pub use detect_columns::*; pub use encode_decode::*; pub use format::*; -use nu_engine::CallExt; pub use parse::*; pub use split::*; pub use str_::*; +use nu_engine::CallExt; use nu_protocol::{ ast::Call, engine::{EngineState, Stack, StateWorkingSet}, diff --git a/crates/nu-command/src/strings/parse.rs b/crates/nu-command/src/strings/parse.rs index 638cd5a93b42..8b2323a04ef9 100644 --- a/crates/nu-command/src/strings/parse.rs +++ b/crates/nu-command/src/strings/parse.rs @@ -1,13 +1,9 @@ -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; - use fancy_regex::Regex; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, ListStream, PipelineData, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, +use nu_engine::command_prelude::*; +use nu_protocol::ListStream; +use std::sync::{ + atomic::{AtomicBool, Ordering}, + Arc, }; #[derive(Clone)] diff --git a/crates/nu-command/src/strings/split/chars.rs b/crates/nu-command/src/strings/split/chars.rs index d91ae4246637..625915e76d32 100644 --- a/crates/nu-command/src/strings/split/chars.rs +++ b/crates/nu-command/src/strings/split/chars.rs @@ -1,9 +1,5 @@ use crate::grapheme_flags; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; use unicode_segmentation::UnicodeSegmentation; #[derive(Clone)] diff --git a/crates/nu-command/src/strings/split/column.rs b/crates/nu-command/src/strings/split/column.rs index 5553b1d8ce9d..9b45e35e08d4 100644 --- a/crates/nu-command/src/strings/split/column.rs +++ b/crates/nu-command/src/strings/split/column.rs @@ -1,10 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, Record, ShellError, Signature, Span, Spanned, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use regex::Regex; #[derive(Clone)] diff --git a/crates/nu-command/src/strings/split/command.rs b/crates/nu-command/src/strings/split/command.rs index 7daf68a193ad..cb52cdb44c7e 100644 --- a/crates/nu-command/src/strings/split/command.rs +++ b/crates/nu-command/src/strings/split/command.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct SplitCommand; diff --git a/crates/nu-command/src/strings/split/list.rs b/crates/nu-command/src/strings/split/list.rs index ce0a171d1244..08bd8fbc61ee 100644 --- a/crates/nu-command/src/strings/split/list.rs +++ b/crates/nu-command/src/strings/split/list.rs @@ -1,10 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; + use regex::Regex; #[derive(Clone)] diff --git a/crates/nu-command/src/strings/split/row.rs b/crates/nu-command/src/strings/split/row.rs index 9a42dff5aba6..8ee22b213cfc 100644 --- a/crates/nu-command/src/strings/split/row.rs +++ b/crates/nu-command/src/strings/split/row.rs @@ -1,11 +1,7 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, - Value, -}; +use nu_engine::command_prelude::*; + use regex::Regex; + #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/strings/split/words.rs b/crates/nu-command/src/strings/split/words.rs index f4d0ea8e77bb..17b68bd44ff7 100644 --- a/crates/nu-command/src/strings/split/words.rs +++ b/crates/nu-command/src/strings/split/words.rs @@ -1,11 +1,7 @@ use crate::grapheme_flags; use fancy_regex::Regex; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use unicode_segmentation::UnicodeSegmentation; #[derive(Clone)] diff --git a/crates/nu-command/src/strings/str_/case/capitalize.rs b/crates/nu-command/src/strings/str_/case/capitalize.rs index 719c511f714e..4cd9a78f6a56 100644 --- a/crates/nu-command/src/strings/str_/case/capitalize.rs +++ b/crates/nu-command/src/strings/str_/case/capitalize.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::record; -use nu_protocol::Category; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/strings/str_/case/downcase.rs b/crates/nu-command/src/strings/str_/case/downcase.rs index f039506fd182..d87b48f91359 100644 --- a/crates/nu-command/src/strings/str_/case/downcase.rs +++ b/crates/nu-command/src/strings/str_/case/downcase.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::record; -use nu_protocol::Category; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/strings/str_/case/mod.rs b/crates/nu-command/src/strings/str_/case/mod.rs index afd934fb4479..32b50c4bc6ac 100644 --- a/crates/nu-command/src/strings/str_/case/mod.rs +++ b/crates/nu-command/src/strings/str_/case/mod.rs @@ -8,12 +8,8 @@ pub use downcase::SubCommand as StrDowncase; pub use str_::Str; pub use upcase::SubCommand as StrUpcase; -use nu_engine::CallExt; - use nu_cmd_base::input_handler::{operate as general_operate, CmdArgument}; -use nu_protocol::ast::{Call, CellPath}; -use nu_protocol::engine::{EngineState, Stack}; -use nu_protocol::{PipelineData, ShellError, Span, Value}; +use nu_engine::command_prelude::*; struct Arguments String + Send + Sync + 'static> { case_operation: &'static F, diff --git a/crates/nu-command/src/strings/str_/case/str_.rs b/crates/nu-command/src/strings/str_/case/str_.rs index a0731972a15c..cf4537f046be 100644 --- a/crates/nu-command/src/strings/str_/case/str_.rs +++ b/crates/nu-command/src/strings/str_/case/str_.rs @@ -1,9 +1,4 @@ -use nu_engine::get_full_help; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, -}; +use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] pub struct Str; diff --git a/crates/nu-command/src/strings/str_/case/upcase.rs b/crates/nu-command/src/strings/str_/case/upcase.rs index 0de75777a391..2e6c7aca5163 100644 --- a/crates/nu-command/src/strings/str_/case/upcase.rs +++ b/crates/nu-command/src/strings/str_/case/upcase.rs @@ -1,9 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/strings/str_/contains.rs b/crates/nu-command/src/strings/str_/contains.rs index 4e56a035be07..bea42ec198fb 100644 --- a/crates/nu-command/src/strings/str_/contains.rs +++ b/crates/nu-command/src/strings/str_/contains.rs @@ -1,12 +1,6 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::record; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use nu_utils::IgnoreCaseExt; #[derive(Clone)] diff --git a/crates/nu-command/src/strings/str_/distance.rs b/crates/nu-command/src/strings/str_/distance.rs index 6c4c02b784bb..2b72454c7adc 100644 --- a/crates/nu-command/src/strings/str_/distance.rs +++ b/crates/nu-command/src/strings/str_/distance.rs @@ -1,11 +1,6 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - levenshtein_distance, record, Category, Example, PipelineData, ShellError, Signature, Span, - SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; +use nu_protocol::levenshtein_distance; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/strings/str_/ends_with.rs b/crates/nu-command/src/strings/str_/ends_with.rs index 0ea1148141c8..5323bf6fcccc 100644 --- a/crates/nu-command/src/strings/str_/ends_with.rs +++ b/crates/nu-command/src/strings/str_/ends_with.rs @@ -1,10 +1,6 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; + use nu_utils::IgnoreCaseExt; struct Arguments { diff --git a/crates/nu-command/src/strings/str_/expand.rs b/crates/nu-command/src/strings/str_/expand.rs index 84cb90791920..2eca9704035f 100644 --- a/crates/nu-command/src/strings/str_/expand.rs +++ b/crates/nu-command/src/strings/str_/expand.rs @@ -1,9 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/strings/str_/index_of.rs b/crates/nu-command/src/strings/str_/index_of.rs index d5f5d198d50d..66b378116ac7 100644 --- a/crates/nu-command/src/strings/str_/index_of.rs +++ b/crates/nu-command/src/strings/str_/index_of.rs @@ -1,13 +1,10 @@ use crate::grapheme_flags; -use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_cmd_base::util; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, Range, ShellError, Signature, Span, Spanned, SyntaxShape, - Type, Value, +use nu_cmd_base::{ + input_handler::{operate, CmdArgument}, + util, }; +use nu_engine::command_prelude::*; +use nu_protocol::Range; use unicode_segmentation::UnicodeSegmentation; struct Arguments { diff --git a/crates/nu-command/src/strings/str_/join.rs b/crates/nu-command/src/strings/str_/join.rs index 1533be5bccc8..732434b20fe2 100644 --- a/crates/nu-command/src/strings/str_/join.rs +++ b/crates/nu-command/src/strings/str_/join.rs @@ -1,10 +1,4 @@ -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, - Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct StrJoin; diff --git a/crates/nu-command/src/strings/str_/length.rs b/crates/nu-command/src/strings/str_/length.rs index 8dccf79410bd..7cfc9d98c133 100644 --- a/crates/nu-command/src/strings/str_/length.rs +++ b/crates/nu-command/src/strings/str_/length.rs @@ -1,12 +1,7 @@ -use crate::grapheme_flags; -use crate::grapheme_flags_const; +use crate::{grapheme_flags, grapheme_flags_const}; use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack, StateWorkingSet}; -use nu_protocol::Category; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; +use nu_protocol::engine::StateWorkingSet; use unicode_segmentation::UnicodeSegmentation; struct Arguments { diff --git a/crates/nu-command/src/strings/str_/replace.rs b/crates/nu-command/src/strings/str_/replace.rs index fa617eea9b98..e8a3290d4fd1 100644 --- a/crates/nu-command/src/strings/str_/replace.rs +++ b/crates/nu-command/src/strings/str_/replace.rs @@ -1,12 +1,6 @@ use fancy_regex::{NoExpand, Regex}; use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - record, Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, - Type, Value, -}; +use nu_engine::command_prelude::*; struct Arguments { all: bool, diff --git a/crates/nu-command/src/strings/str_/reverse.rs b/crates/nu-command/src/strings/str_/reverse.rs index 7abf28c45fdd..6faa05174643 100644 --- a/crates/nu-command/src/strings/str_/reverse.rs +++ b/crates/nu-command/src/strings/str_/reverse.rs @@ -1,10 +1,5 @@ use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/strings/str_/starts_with.rs b/crates/nu-command/src/strings/str_/starts_with.rs index 9b0ef9701c04..ec94204d734d 100644 --- a/crates/nu-command/src/strings/str_/starts_with.rs +++ b/crates/nu-command/src/strings/str_/starts_with.rs @@ -1,11 +1,6 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::Spanned; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value}; +use nu_engine::command_prelude::*; + use nu_utils::IgnoreCaseExt; struct Arguments { diff --git a/crates/nu-command/src/strings/str_/stats.rs b/crates/nu-command/src/strings/str_/stats.rs index fbd7f9ea7926..d362393e8ec3 100644 --- a/crates/nu-command/src/strings/str_/stats.rs +++ b/crates/nu-command/src/strings/str_/stats.rs @@ -1,9 +1,5 @@ use fancy_regex::Regex; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, -}; +use nu_engine::command_prelude::*; use std::collections::BTreeMap; use std::{fmt, str}; use unicode_segmentation::UnicodeSegmentation; diff --git a/crates/nu-command/src/strings/str_/substring.rs b/crates/nu-command/src/strings/str_/substring.rs index cdff05190f37..8934a861e2a6 100644 --- a/crates/nu-command/src/strings/str_/substring.rs +++ b/crates/nu-command/src/strings/str_/substring.rs @@ -1,14 +1,10 @@ use crate::grapheme_flags; -use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_cmd_base::util; -use nu_engine::CallExt; -use nu_protocol::ast::Call; -use nu_protocol::ast::CellPath; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::{ - Example, PipelineData, Range, ShellError, Signature, Span, SyntaxShape, Type, Value, +use nu_cmd_base::{ + input_handler::{operate, CmdArgument}, + util, }; +use nu_engine::command_prelude::*; +use nu_protocol::Range; use std::cmp::Ordering; use unicode_segmentation::UnicodeSegmentation; diff --git a/crates/nu-command/src/strings/str_/trim/trim_.rs b/crates/nu-command/src/strings/str_/trim/trim_.rs index e23c29d0194f..9d0b9530b3e5 100644 --- a/crates/nu-command/src/strings/str_/trim/trim_.rs +++ b/crates/nu-command/src/strings/str_/trim/trim_.rs @@ -1,11 +1,5 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, - Value, -}; +use nu_engine::command_prelude::*; #[derive(Clone)] pub struct SubCommand; diff --git a/crates/nu-command/src/system/complete.rs b/crates/nu-command/src/system/complete.rs index 5768ba5977c6..2428dd09948d 100644 --- a/crates/nu-command/src/system/complete.rs +++ b/crates/nu-command/src/system/complete.rs @@ -1,10 +1,5 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, IntoSpanned, IoStream, PipelineData, Record, ShellError, - Signature, Type, Value, -}; - +use nu_engine::command_prelude::*; +use nu_protocol::IoStream; use std::thread; #[derive(Clone)] diff --git a/crates/nu-command/src/system/exec.rs b/crates/nu-command/src/system/exec.rs index 95cb8d221a4f..79c343babcb1 100644 --- a/crates/nu-command/src/system/exec.rs +++ b/crates/nu-command/src/system/exec.rs @@ -1,10 +1,6 @@ use super::run_external::create_external_command; -use nu_engine::current_dir; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IoStream, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, -}; +use nu_engine::{command_prelude::*, current_dir}; +use nu_protocol::IoStream; #[derive(Clone)] pub struct Exec; diff --git a/crates/nu-command/src/system/nu_check.rs b/crates/nu-command/src/system/nu_check.rs index 90363782013f..8876e82c084e 100644 --- a/crates/nu-command/src/system/nu_check.rs +++ b/crates/nu-command/src/system/nu_check.rs @@ -1,11 +1,6 @@ -use nu_engine::{env::get_config, find_in_dirs_env, get_dirs_var_from_call, CallExt}; +use nu_engine::{command_prelude::*, env::get_config, find_in_dirs_env, get_dirs_var_from_call}; use nu_parser::{parse, parse_module_block, parse_module_file_or_dir, unescape_unquote_string}; -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack, StateWorkingSet}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; - +use nu_protocol::engine::StateWorkingSet; use std::path::Path; #[derive(Clone)] diff --git a/crates/nu-command/src/system/ps.rs b/crates/nu-command/src/system/ps.rs index 1592d6622903..418aaf76ff18 100644 --- a/crates/nu-command/src/system/ps.rs +++ b/crates/nu-command/src/system/ps.rs @@ -1,19 +1,7 @@ #[cfg(windows)] use itertools::Itertools; -use nu_engine::CallExt; -#[cfg(all( - unix, - not(target_os = "macos"), - not(target_os = "windows"), - not(target_os = "android"), -))] -use nu_protocol::Span; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoInterruptiblePipelineData, PipelineData, Record, ShellError, Signature, - Type, Value, -}; +use nu_engine::command_prelude::*; + #[cfg(all( unix, not(target_os = "freebsd"), @@ -22,7 +10,6 @@ use nu_protocol::{ not(target_os = "android"), ))] use procfs::WithCurrentSystemInfo; - use std::time::Duration; #[derive(Clone)] diff --git a/crates/nu-command/src/system/registry_query.rs b/crates/nu-command/src/system/registry_query.rs index 050457602f91..c926ad6aafef 100644 --- a/crates/nu-command/src/system/registry_query.rs +++ b/crates/nu-command/src/system/registry_query.rs @@ -1,10 +1,5 @@ -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, - ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use windows::{core::PCWSTR, Win32::System::Environment::ExpandEnvironmentStringsW}; use winreg::{enums::*, types::FromRegValue, RegKey}; diff --git a/crates/nu-command/src/system/run_external.rs b/crates/nu-command/src/system/run_external.rs index 126065f49c59..04504166cfcd 100644 --- a/crates/nu-command/src/system/run_external.rs +++ b/crates/nu-command/src/system/run_external.rs @@ -1,25 +1,18 @@ use nu_cmd_base::hook::eval_hook; -use nu_engine::env_to_strings; -use nu_engine::get_eval_expression; -use nu_engine::CallExt; -use nu_protocol::{ - ast::{Call, Expr}, - did_you_mean, - engine::{Command, EngineState, Stack}, - Category, Example, IntoSpanned, IoStream, ListStream, NuGlob, PipelineData, RawStream, - ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, -}; +use nu_engine::{command_prelude::*, env_to_strings, get_eval_expression}; +use nu_protocol::{ast::Expr, did_you_mean, IoStream, ListStream, NuGlob, RawStream}; use nu_system::ForegroundChild; use nu_utils::IgnoreCaseExt; use os_pipe::PipeReader; use pathdiff::diff_paths; -use std::collections::HashMap; -use std::io::{BufRead, BufReader, Read, Write}; -use std::path::{Path, PathBuf}; -use std::process::{Command as CommandSys, Stdio}; -use std::sync::mpsc; -use std::sync::Arc; -use std::thread; +use std::{ + collections::HashMap, + io::{BufRead, BufReader, Read, Write}, + path::{Path, PathBuf}, + process::{Command as CommandSys, Stdio}, + sync::{mpsc, Arc}, + thread, +}; #[derive(Clone)] pub struct External; diff --git a/crates/nu-command/src/system/sys.rs b/crates/nu-command/src/system/sys.rs index 8b3b30c77589..6c6d8b6bda8d 100644 --- a/crates/nu-command/src/system/sys.rs +++ b/crates/nu-command/src/system/sys.rs @@ -1,11 +1,6 @@ -use chrono::prelude::DateTime; -use chrono::Local; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Example, IntoPipelineData, LazyRecord, PipelineData, Record, ShellError, - Signature, Span, Type, Value, -}; +use chrono::{DateTime, Local}; +use nu_engine::command_prelude::*; +use nu_protocol::LazyRecord; use std::time::{Duration, UNIX_EPOCH}; use sysinfo::{ Components, CpuRefreshKind, Disks, Networks, System, Users, MINIMUM_CPU_UPDATE_INTERVAL, diff --git a/crates/nu-command/src/system/which_.rs b/crates/nu-command/src/system/which_.rs index 4d4fdcd32bb6..21ab7b0d9fb7 100644 --- a/crates/nu-command/src/system/which_.rs +++ b/crates/nu-command/src/system/which_.rs @@ -1,16 +1,6 @@ use log::trace; -use nu_engine::env; -use nu_engine::CallExt; -use nu_protocol::record; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, - Spanned, SyntaxShape, Type, Value, -}; - -use std::ffi::OsStr; -use std::path::Path; +use nu_engine::{command_prelude::*, env}; +use std::{ffi::OsStr, path::Path}; #[derive(Clone)] pub struct Which; diff --git a/crates/nu-command/src/viewers/griddle.rs b/crates/nu-command/src/viewers/griddle.rs index 217cfabfed30..be4f4be49f97 100644 --- a/crates/nu-command/src/viewers/griddle.rs +++ b/crates/nu-command/src/viewers/griddle.rs @@ -1,17 +1,12 @@ // use super::icons::{icon_for_file, iconify_style_ansi_to_nu}; use super::icons::icon_for_file; use lscolors::Style; -use nu_engine::env_to_string; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Config, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, - Type, Value, -}; +use nu_engine::{command_prelude::*, env_to_string}; +use nu_protocol::Config; use nu_term_grid::grid::{Alignment, Cell, Direction, Filling, Grid, GridOptions}; use nu_utils::get_ls_colors; use terminal_size::{Height, Width}; + #[derive(Clone)] pub struct Griddle; diff --git a/crates/nu-command/src/viewers/icons.rs b/crates/nu-command/src/viewers/icons.rs index 88357be3f075..6443063e7bf5 100644 --- a/crates/nu-command/src/viewers/icons.rs +++ b/crates/nu-command/src/viewers/icons.rs @@ -1,7 +1,6 @@ use nu_protocol::{ShellError, Span}; use once_cell::sync::Lazy; -use std::collections::HashMap; -use std::path::Path; +use std::{collections::HashMap, path::Path}; // Attribution: Thanks exa. Most of this file is taken from around here // https://github.com/ogham/exa/blob/dbd11d38042284cc890fdd91760c2f93b65e8553/src/output/icons.rs diff --git a/crates/nu-command/src/viewers/table.rs b/crates/nu-command/src/viewers/table.rs index 67bc5ca1edc2..fdcd1af01a69 100644 --- a/crates/nu-command/src/viewers/table.rs +++ b/crates/nu-command/src/viewers/table.rs @@ -3,28 +3,18 @@ // the goal is to configure it once... use lscolors::{LsColors, Style}; -use nu_color_config::color_from_hex; -use nu_color_config::{StyleComputer, TextStyle}; -use nu_engine::{env::get_config, env_to_string, CallExt}; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - record, Category, Config, DataSource, Example, IntoPipelineData, ListStream, PipelineData, - PipelineMetadata, RawStream, Record, ShellError, Signature, Span, SyntaxShape, TableMode, Type, - Value, -}; -use nu_table::common::create_nu_table_config; +use nu_color_config::{color_from_hex, StyleComputer, TextStyle}; +use nu_engine::{command_prelude::*, env::get_config, env_to_string}; +use nu_protocol::{Config, DataSource, ListStream, PipelineMetadata, RawStream, TableMode}; use nu_table::{ - CollapsedTable, ExpandedTable, JustTable, NuTable, NuTableCell, StringResult, TableOpts, - TableOutput, + common::create_nu_table_config, CollapsedTable, ExpandedTable, JustTable, NuTable, NuTableCell, + StringResult, TableOpts, TableOutput, }; use nu_utils::get_ls_colors; -use std::collections::VecDeque; -use std::io::IsTerminal; -use std::str::FromStr; -use std::sync::Arc; -use std::time::Instant; -use std::{path::PathBuf, sync::atomic::AtomicBool}; +use std::{ + collections::VecDeque, io::IsTerminal, path::PathBuf, str::FromStr, sync::atomic::AtomicBool, + sync::Arc, time::Instant, +}; use terminal_size::{Height, Width}; use url::Url; diff --git a/crates/nu-engine/src/call_ext.rs b/crates/nu-engine/src/call_ext.rs index 3b320d8936fc..517b9fbf1289 100644 --- a/crates/nu-engine/src/call_ext.rs +++ b/crates/nu-engine/src/call_ext.rs @@ -1,13 +1,12 @@ -use nu_protocol::debugger::WithoutDebug; +use crate::eval_expression; use nu_protocol::{ ast::Call, + debugger::WithoutDebug, engine::{EngineState, Stack, StateWorkingSet}, eval_const::eval_constant, FromValue, ShellError, Value, }; -use crate::eval_expression; - pub trait CallExt { /// Check if a boolean flag is set (i.e. `--bool` or `--bool=true`) fn has_flag( diff --git a/crates/nu-engine/src/command_prelude.rs b/crates/nu-engine/src/command_prelude.rs new file mode 100644 index 000000000000..27646296834a --- /dev/null +++ b/crates/nu-engine/src/command_prelude.rs @@ -0,0 +1,7 @@ +pub use crate::CallExt; +pub use nu_protocol::{ + ast::{Call, CellPath}, + engine::{Command, EngineState, Stack}, + record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, IntoSpanned, + PipelineData, Record, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, +}; diff --git a/crates/nu-engine/src/documentation.rs b/crates/nu-engine/src/documentation.rs index d0109b026b05..463f8f10e77b 100644 --- a/crates/nu-engine/src/documentation.rs +++ b/crates/nu-engine/src/documentation.rs @@ -1,15 +1,13 @@ -use nu_protocol::ast::{Argument, Expr, Expression, RecordItem}; -use nu_protocol::debugger::WithoutDebug; +use crate::eval_call; use nu_protocol::{ - ast::Call, + ast::{Argument, Call, Expr, Expression, RecordItem}, + debugger::WithoutDebug, engine::{EngineState, Stack}, record, Category, Example, IntoPipelineData, PipelineData, Signature, Span, SyntaxShape, Type, Value, }; use std::{collections::HashMap, fmt::Write}; -use crate::eval_call; - pub fn get_full_help( sig: &Signature, examples: &[Example], diff --git a/crates/nu-engine/src/env.rs b/crates/nu-engine/src/env.rs index 8a83b6e4fec5..b8b57fd88ec5 100644 --- a/crates/nu-engine/src/env.rs +++ b/crates/nu-engine/src/env.rs @@ -1,15 +1,16 @@ -use std::collections::HashMap; -use std::path::{Path, PathBuf}; -use std::sync::Arc; - -use nu_protocol::ast::{Call, Expr}; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet, PWD_ENV}; -use nu_protocol::{Config, PipelineData, ShellError, Span, Value, VarId}; - -use nu_path::canonicalize_with; -use nu_protocol::debugger::WithoutDebug; - use crate::eval_block; +use nu_path::canonicalize_with; +use nu_protocol::{ + ast::{Call, Expr}, + debugger::WithoutDebug, + engine::{EngineState, Stack, StateWorkingSet, PWD_ENV}, + Config, PipelineData, ShellError, Span, Value, VarId, +}; +use std::{ + collections::HashMap, + path::{Path, PathBuf}, + sync::Arc, +}; #[cfg(windows)] const ENV_PATH_NAME: &str = "Path"; diff --git a/crates/nu-engine/src/eval.rs b/crates/nu-engine/src/eval.rs index bd9daa69768f..de4d4c6b4385 100644 --- a/crates/nu-engine/src/eval.rs +++ b/crates/nu-engine/src/eval.rs @@ -1,18 +1,17 @@ -use std::{borrow::Cow, fs::OpenOptions, path::PathBuf}; - use crate::{current_dir, current_dir_str, get_config, get_full_help}; use nu_path::expand_path_with; -use nu_protocol::debugger::DebugContext; use nu_protocol::{ ast::{ Assignment, Block, Call, Expr, Expression, ExternalArgument, PathMember, PipelineElement, PipelineRedirection, RedirectionSource, RedirectionTarget, }, + debugger::DebugContext, engine::{Closure, EngineState, Redirection, Stack}, eval_base::Eval, Config, FromValue, IntoPipelineData, IoStream, PipelineData, ShellError, Span, Spanned, Type, Value, VarId, ENV_VARIABLE_ID, }; +use std::{borrow::Cow, fs::OpenOptions, path::PathBuf}; pub fn eval_call( engine_state: &EngineState, diff --git a/crates/nu-engine/src/eval_helpers.rs b/crates/nu-engine/src/eval_helpers.rs index 3c4781becf38..66bda3e0eb8c 100644 --- a/crates/nu-engine/src/eval_helpers.rs +++ b/crates/nu-engine/src/eval_helpers.rs @@ -2,10 +2,12 @@ use crate::{ eval_block, eval_block_with_early_return, eval_expression, eval_expression_with_input, eval_subexpression, }; -use nu_protocol::ast::{Block, Expression}; -use nu_protocol::debugger::{WithDebug, WithoutDebug}; -use nu_protocol::engine::{EngineState, Stack}; -use nu_protocol::{PipelineData, ShellError, Value}; +use nu_protocol::{ + ast::{Block, Expression}, + debugger::{WithDebug, WithoutDebug}, + engine::{EngineState, Stack}, + PipelineData, ShellError, Value, +}; /// Type of eval_block() function pub type EvalBlockFn = diff --git a/crates/nu-engine/src/glob_from.rs b/crates/nu-engine/src/glob_from.rs index d195ba34334a..2847a3c5b422 100644 --- a/crates/nu-engine/src/glob_from.rs +++ b/crates/nu-engine/src/glob_from.rs @@ -1,12 +1,11 @@ +use nu_glob::MatchOptions; +use nu_path::{canonicalize_with, expand_path_with}; +use nu_protocol::{NuGlob, ShellError, Span, Spanned}; use std::{ fs, path::{Component, Path, PathBuf}, }; -use nu_glob::MatchOptions; -use nu_path::{canonicalize_with, expand_path_with}; -use nu_protocol::{NuGlob, ShellError, Span, Spanned}; - const GLOB_CHARS: &[char] = &['*', '?', '[']; /// This function is like `nu_glob::glob` from the `glob` crate, except it is relative to a given cwd. diff --git a/crates/nu-engine/src/lib.rs b/crates/nu-engine/src/lib.rs index f013babefea3..ca1df34aff76 100644 --- a/crates/nu-engine/src/lib.rs +++ b/crates/nu-engine/src/lib.rs @@ -1,5 +1,6 @@ mod call_ext; pub mod column; +pub mod command_prelude; pub mod documentation; pub mod env; mod eval; diff --git a/crates/nu-engine/src/scope.rs b/crates/nu-engine/src/scope.rs index c48dc94a8ab0..e4cf8b45c055 100644 --- a/crates/nu-engine/src/scope.rs +++ b/crates/nu-engine/src/scope.rs @@ -3,8 +3,7 @@ use nu_protocol::{ engine::{Command, EngineState, Stack, Visibility}, record, ModuleId, Signature, Span, SyntaxShape, Type, Value, }; -use std::cmp::Ordering; -use std::collections::HashMap; +use std::{cmp::Ordering, collections::HashMap}; pub struct ScopeData<'e, 's> { engine_state: &'e EngineState, diff --git a/crates/nu-explore/src/commands/expand.rs b/crates/nu-explore/src/commands/expand.rs index 122ce3c19e5c..c9c22fbdb578 100644 --- a/crates/nu-explore/src/commands/expand.rs +++ b/crates/nu-explore/src/commands/expand.rs @@ -1,17 +1,14 @@ -use std::{io::Result, vec}; - +use super::{HelpManual, Shortcode, ViewCommand}; +use crate::{ + nu_common::{self, collect_input}, + views::Preview, +}; use nu_color_config::StyleComputer; use nu_protocol::{ engine::{EngineState, Stack}, Value, }; - -use crate::{ - nu_common::{self, collect_input}, - views::Preview, -}; - -use super::{HelpManual, Shortcode, ViewCommand}; +use std::{io::Result, vec}; #[derive(Default, Clone)] pub struct ExpandCmd; diff --git a/crates/nu-explore/src/commands/help.rs b/crates/nu-explore/src/commands/help.rs index 4245df07ef69..08bc28d83e5f 100644 --- a/crates/nu-explore/src/commands/help.rs +++ b/crates/nu-explore/src/commands/help.rs @@ -1,21 +1,20 @@ -use std::collections::HashMap; -use std::io::{self, Result}; - +use super::{HelpExample, HelpManual, ViewCommand}; +use crate::{ + nu_common::{collect_input, NuSpan}, + pager::{Frame, Transition, ViewInfo}, + views::{Layout, Preview, RecordView, View, ViewConfig}, +}; use crossterm::event::KeyEvent; use nu_protocol::{ engine::{EngineState, Stack}, record, Value, }; use ratatui::layout::Rect; - -use crate::{ - nu_common::{collect_input, NuSpan}, - pager::{Frame, Transition, ViewInfo}, - views::{Layout, Preview, RecordView, View, ViewConfig}, +use std::{ + collections::HashMap, + io::{self, Result}, }; -use super::{HelpExample, HelpManual, ViewCommand}; - #[derive(Debug, Default, Clone)] pub struct HelpCmd { input_command: String, diff --git a/crates/nu-explore/src/commands/mod.rs b/crates/nu-explore/src/commands/mod.rs index 3f58e70a0f4f..3755746127d3 100644 --- a/crates/nu-explore/src/commands/mod.rs +++ b/crates/nu-explore/src/commands/mod.rs @@ -1,10 +1,8 @@ +use super::pager::{Pager, Transition}; use nu_protocol::{ engine::{EngineState, Stack}, Value, }; - -use super::pager::{Pager, Transition}; - use std::{borrow::Cow, io::Result}; mod expand; diff --git a/crates/nu-explore/src/commands/nu.rs b/crates/nu-explore/src/commands/nu.rs index 635a9ad2a37e..1c0354d6b068 100644 --- a/crates/nu-explore/src/commands/nu.rs +++ b/crates/nu-explore/src/commands/nu.rs @@ -1,18 +1,15 @@ -use std::io::{self, Result}; - -use nu_protocol::{ - engine::{EngineState, Stack}, - PipelineData, Value, -}; -use ratatui::layout::Rect; - +use super::{HelpExample, HelpManual, ViewCommand}; use crate::{ nu_common::{collect_pipeline, has_simple_value, run_command_with_value}, pager::Frame, views::{Layout, Orientation, Preview, RecordView, View, ViewConfig}, }; - -use super::{HelpExample, HelpManual, ViewCommand}; +use nu_protocol::{ + engine::{EngineState, Stack}, + PipelineData, Value, +}; +use ratatui::layout::Rect; +use std::io::{self, Result}; #[derive(Debug, Default, Clone)] pub struct NuCmd { diff --git a/crates/nu-explore/src/commands/quit.rs b/crates/nu-explore/src/commands/quit.rs index 2e465045804f..8d232b795bf3 100644 --- a/crates/nu-explore/src/commands/quit.rs +++ b/crates/nu-explore/src/commands/quit.rs @@ -1,13 +1,10 @@ -use std::io::Result; - +use super::{HelpManual, SimpleCommand}; +use crate::pager::{Pager, Transition}; use nu_protocol::{ engine::{EngineState, Stack}, Value, }; - -use crate::pager::{Pager, Transition}; - -use super::{HelpManual, SimpleCommand}; +use std::io::Result; #[derive(Default, Clone)] pub struct QuitCmd; diff --git a/crates/nu-explore/src/commands/table.rs b/crates/nu-explore/src/commands/table.rs index 6ef36697ef62..daac313a706d 100644 --- a/crates/nu-explore/src/commands/table.rs +++ b/crates/nu-explore/src/commands/table.rs @@ -1,20 +1,17 @@ -use std::io::Result; - -use nu_ansi_term::Style; -use nu_protocol::{ - engine::{EngineState, Stack}, - Value, +use super::{ + default_color_list, default_int_list, ConfigOption, HelpExample, HelpManual, Shortcode, + ViewCommand, }; - use crate::{ nu_common::collect_input, views::{Orientation, RecordView}, }; - -use super::{ - default_color_list, default_int_list, ConfigOption, HelpExample, HelpManual, Shortcode, - ViewCommand, +use nu_ansi_term::Style; +use nu_protocol::{ + engine::{EngineState, Stack}, + Value, }; +use std::io::Result; #[derive(Debug, Default, Clone)] pub struct TableCmd { diff --git a/crates/nu-explore/src/commands/try.rs b/crates/nu-explore/src/commands/try.rs index feaa468d4946..4c4c8815963a 100644 --- a/crates/nu-explore/src/commands/try.rs +++ b/crates/nu-explore/src/commands/try.rs @@ -1,13 +1,10 @@ -use std::io::{Error, ErrorKind, Result}; - +use super::{default_color_list, ConfigOption, HelpExample, HelpManual, Shortcode, ViewCommand}; +use crate::views::InteractiveView; use nu_protocol::{ engine::{EngineState, Stack}, Value, }; - -use crate::views::InteractiveView; - -use super::{default_color_list, ConfigOption, HelpExample, HelpManual, Shortcode, ViewCommand}; +use std::io::{Error, ErrorKind, Result}; #[derive(Debug, Default, Clone)] pub struct TryCmd { diff --git a/crates/nu-explore/src/explore.rs b/crates/nu-explore/src/explore.rs index d5720683141c..3b2912dbc413 100644 --- a/crates/nu-explore/src/explore.rs +++ b/crates/nu-explore/src/explore.rs @@ -5,12 +5,8 @@ use crate::{ }; use nu_ansi_term::{Color, Style}; use nu_color_config::{get_color_map, StyleComputer}; -use nu_engine::CallExt; -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; +use nu_engine::command_prelude::*; + use std::collections::HashMap; /// A `less` like program to render a [`Value`] as a table. diff --git a/crates/nu-explore/src/lib.rs b/crates/nu-explore/src/lib.rs index 7f9d134c6536..3492eb0533b4 100644 --- a/crates/nu-explore/src/lib.rs +++ b/crates/nu-explore/src/lib.rs @@ -9,21 +9,18 @@ mod views; pub use default_context::add_explore_context; pub use explore::Explore; -use std::io; - use commands::{ExpandCmd, HelpCmd, HelpManual, NuCmd, QuitCmd, TableCmd, TryCmd}; use nu_common::{collect_pipeline, has_simple_value, CtrlC}; use nu_protocol::{ engine::{EngineState, Stack}, PipelineData, Value, }; -use pager::{Page, Pager}; +use pager::{Page, Pager, PagerConfig, StyleConfig}; use registry::{Command, CommandRegistry}; +use std::io; use terminal_size::{Height, Width}; use views::{BinaryView, InformationView, Orientation, Preview, RecordView}; -use pager::{PagerConfig, StyleConfig}; - mod util { pub use super::nu_common::{create_lscolors, create_map, map_into_value}; } diff --git a/crates/nu-explore/src/nu_common/command.rs b/crates/nu-explore/src/nu_common/command.rs index bffc7b256bb7..add3940e75b6 100644 --- a/crates/nu-explore/src/nu_common/command.rs +++ b/crates/nu-explore/src/nu_common/command.rs @@ -1,12 +1,11 @@ -use std::sync::Arc; - use nu_engine::eval_block; use nu_parser::parse; -use nu_protocol::debugger::WithoutDebug; use nu_protocol::{ + debugger::WithoutDebug, engine::{EngineState, Redirection, Stack, StateWorkingSet}, IoStream, PipelineData, ShellError, Value, }; +use std::sync::Arc; pub fn run_command_with_value( command: &str, diff --git a/crates/nu-explore/src/nu_common/lscolor.rs b/crates/nu-explore/src/nu_common/lscolor.rs index c2e46251c587..31a5571ef513 100644 --- a/crates/nu-explore/src/nu_common/lscolor.rs +++ b/crates/nu-explore/src/nu_common/lscolor.rs @@ -1,12 +1,10 @@ -use std::fs::symlink_metadata; - +use super::NuText; use lscolors::LsColors; use nu_ansi_term::{Color, Style}; use nu_engine::env_to_string; use nu_protocol::engine::{EngineState, Stack}; use nu_utils::get_ls_colors; - -use super::NuText; +use std::fs::symlink_metadata; pub fn create_lscolors(engine_state: &EngineState, stack: &Stack) -> LsColors { let colors = stack diff --git a/crates/nu-explore/src/nu_common/mod.rs b/crates/nu-explore/src/nu_common/mod.rs index 290be0490489..78bb61db7279 100644 --- a/crates/nu-explore/src/nu_common/mod.rs +++ b/crates/nu-explore/src/nu_common/mod.rs @@ -4,10 +4,9 @@ mod string; mod table; mod value; -use std::sync::{atomic::AtomicBool, Arc}; - use nu_color_config::TextStyle; use nu_protocol::Value; +use std::sync::{atomic::AtomicBool, Arc}; pub use nu_ansi_term::{Color as NuColor, Style as NuStyle}; pub use nu_protocol::{Config as NuConfig, Span as NuSpan}; diff --git a/crates/nu-explore/src/nu_common/table.rs b/crates/nu-explore/src/nu_common/table.rs index b49ed7eb9235..b1d0a4c97419 100644 --- a/crates/nu-explore/src/nu_common/table.rs +++ b/crates/nu-explore/src/nu_common/table.rs @@ -1,13 +1,11 @@ +use crate::nu_common::NuConfig; use nu_color_config::StyleComputer; use nu_protocol::{Record, Span, Value}; use nu_table::{ common::{nu_value_to_string, nu_value_to_string_clean}, ExpandedTable, TableOpts, }; -use std::sync::atomic::AtomicBool; -use std::sync::Arc; - -use crate::nu_common::NuConfig; +use std::sync::{atomic::AtomicBool, Arc}; pub fn try_build_table( ctrlc: Option>, diff --git a/crates/nu-explore/src/nu_common/value.rs b/crates/nu-explore/src/nu_common/value.rs index 05f83ddfa83f..5f25a1131eb1 100644 --- a/crates/nu-explore/src/nu_common/value.rs +++ b/crates/nu-explore/src/nu_common/value.rs @@ -1,9 +1,7 @@ -use std::collections::HashMap; - +use super::NuSpan; use nu_engine::get_columns; use nu_protocol::{record, ListStream, PipelineData, PipelineMetadata, RawStream, Value}; - -use super::NuSpan; +use std::collections::HashMap; pub fn collect_pipeline(input: PipelineData) -> (Vec, Vec>) { match input { diff --git a/crates/nu-explore/src/pager/mod.rs b/crates/nu-explore/src/pager/mod.rs index 3698e516f268..d82e1669b122 100644 --- a/crates/nu-explore/src/pager/mod.rs +++ b/crates/nu-explore/src/pager/mod.rs @@ -3,15 +3,18 @@ mod events; pub mod report; mod status_bar; -use std::{ - cmp::min, - io::{self, Result, Stdout}, - result, - sync::atomic::Ordering, +use self::{ + command_bar::CommandBar, + report::{Report, Severity}, + status_bar::StatusBar, +}; +use super::views::{Layout, View}; +use crate::{ + nu_common::{CtrlC, NuColor, NuConfig, NuSpan, NuStyle}, + registry::{Command, CommandRegistry}, + util::map_into_value, + views::{util::nu_style_to_tui, ViewConfig}, }; - -use std::collections::HashMap; - use crossterm::{ event::{KeyCode, KeyEvent, KeyModifiers}, execute, @@ -20,6 +23,7 @@ use crossterm::{ LeaveAlternateScreen, }, }; +use events::UIEvents; use lscolors::LsColors; use nu_color_config::{lookup_ansi_color_style, StyleComputer}; use nu_protocol::{ @@ -27,24 +31,14 @@ use nu_protocol::{ Record, Value, }; use ratatui::{backend::CrosstermBackend, layout::Rect, widgets::Block}; - -use crate::{ - nu_common::{CtrlC, NuColor, NuConfig, NuSpan, NuStyle}, - registry::{Command, CommandRegistry}, - util::map_into_value, - views::{util::nu_style_to_tui, ViewConfig}, -}; - -use self::{ - command_bar::CommandBar, - report::{Report, Severity}, - status_bar::StatusBar, +use std::{ + cmp::min, + collections::HashMap, + io::{self, Result, Stdout}, + result, + sync::atomic::Ordering, }; -use super::views::{Layout, View}; - -use events::UIEvents; - pub type Frame<'a> = ratatui::Frame<'a>; pub type Terminal = ratatui::Terminal>; pub type ConfigMap = HashMap; diff --git a/crates/nu-explore/src/views/information.rs b/crates/nu-explore/src/views/information.rs index 4727f3f68b00..ec99f875a1ac 100644 --- a/crates/nu-explore/src/views/information.rs +++ b/crates/nu-explore/src/views/information.rs @@ -1,14 +1,12 @@ -use crossterm::event::KeyEvent; -use nu_color_config::TextStyle; -use nu_protocol::engine::{EngineState, Stack}; -use ratatui::{layout::Rect, widgets::Paragraph}; - +use super::{Layout, View, ViewConfig}; use crate::{ nu_common::NuText, pager::{Frame, Transition, ViewInfo}, }; - -use super::{Layout, View, ViewConfig}; +use crossterm::event::KeyEvent; +use nu_color_config::TextStyle; +use nu_protocol::engine::{EngineState, Stack}; +use ratatui::{layout::Rect, widgets::Paragraph}; #[derive(Debug, Default)] pub struct InformationView; diff --git a/crates/nu-explore/src/views/interactive.rs b/crates/nu-explore/src/views/interactive.rs index 6feb565ae84b..aeb164b7229a 100644 --- a/crates/nu-explore/src/views/interactive.rs +++ b/crates/nu-explore/src/views/interactive.rs @@ -1,5 +1,13 @@ -use std::cmp::min; - +use super::{ + record::{RecordView, TableTheme}, + util::{lookup_tui_color, nu_style_to_tui}, + Layout, Orientation, View, ViewConfig, +}; +use crate::{ + nu_common::{collect_pipeline, run_command_with_value}, + pager::{report::Report, Frame, Transition, ViewInfo}, + util::create_map, +}; use crossterm::event::{KeyCode, KeyEvent}; use nu_color_config::get_color_map; use nu_protocol::{ @@ -11,18 +19,7 @@ use ratatui::{ style::{Modifier, Style}, widgets::{BorderType, Borders, Paragraph}, }; - -use crate::{ - nu_common::{collect_pipeline, run_command_with_value}, - pager::{report::Report, Frame, Transition, ViewInfo}, - util::create_map, -}; - -use super::{ - record::{RecordView, TableTheme}, - util::{lookup_tui_color, nu_style_to_tui}, - Layout, Orientation, View, ViewConfig, -}; +use std::cmp::min; pub struct InteractiveView<'a> { input: Value, diff --git a/crates/nu-explore/src/views/mod.rs b/crates/nu-explore/src/views/mod.rs index 25f60e3d35bd..1a6e0c9942d5 100644 --- a/crates/nu-explore/src/views/mod.rs +++ b/crates/nu-explore/src/views/mod.rs @@ -7,6 +7,11 @@ mod preview; mod record; pub mod util; +use super::{ + nu_common::NuText, + pager::{Frame, Transition, ViewInfo}, +}; +use crate::{nu_common::NuConfig, pager::ConfigMap}; use crossterm::event::KeyEvent; use lscolors::LsColors; use nu_color_config::StyleComputer; @@ -16,13 +21,6 @@ use nu_protocol::{ }; use ratatui::layout::Rect; -use crate::{nu_common::NuConfig, pager::ConfigMap}; - -use super::{ - nu_common::NuText, - pager::{Frame, Transition, ViewInfo}, -}; - pub use binary::BinaryView; pub use information::InformationView; pub use interactive::InteractiveView; diff --git a/crates/nu-explore/src/views/preview.rs b/crates/nu-explore/src/views/preview.rs index 5fdf6159fc18..2bd495144ba0 100644 --- a/crates/nu-explore/src/views/preview.rs +++ b/crates/nu-explore/src/views/preview.rs @@ -1,5 +1,8 @@ -use std::cmp::max; - +use super::{coloredtextw::ColoredTextW, cursor::XYCursor, Layout, View, ViewConfig}; +use crate::{ + nu_common::{NuSpan, NuText}, + pager::{report::Report, Frame, Transition, ViewInfo}, +}; use crossterm::event::{KeyCode, KeyEvent}; use nu_color_config::TextStyle; use nu_protocol::{ @@ -7,13 +10,7 @@ use nu_protocol::{ Value, }; use ratatui::layout::Rect; - -use crate::{ - nu_common::{NuSpan, NuText}, - pager::{report::Report, Frame, Transition, ViewInfo}, -}; - -use super::{coloredtextw::ColoredTextW, cursor::XYCursor, Layout, View, ViewConfig}; +use std::cmp::max; // todo: Add wrap option #[derive(Debug)] diff --git a/crates/nu-explore/src/views/record/mod.rs b/crates/nu-explore/src/views/record/mod.rs index 1929f8f5f04e..bcfc0317e661 100644 --- a/crates/nu-explore/src/views/record/mod.rs +++ b/crates/nu-explore/src/views/record/mod.rs @@ -1,17 +1,11 @@ mod tablew; -use std::borrow::Cow; - -use std::collections::HashMap; - -use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; -use nu_color_config::{get_color_map, StyleComputer}; -use nu_protocol::{ - engine::{EngineState, Stack}, - Record, Value, +use self::tablew::{TableStyle, TableW, TableWState}; +use super::{ + cursor::XYCursor, + util::{make_styled_string, nu_style_to_tui}, + Layout, View, ViewConfig, }; -use ratatui::{layout::Rect, widgets::Block}; - use crate::{ nu_common::{collect_input, lscolorize, NuConfig, NuSpan, NuStyle, NuText}, pager::{ @@ -21,14 +15,14 @@ use crate::{ util::create_map, views::ElementInfo, }; - -use self::tablew::{TableStyle, TableW, TableWState}; - -use super::{ - cursor::XYCursor, - util::{make_styled_string, nu_style_to_tui}, - Layout, View, ViewConfig, +use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; +use nu_color_config::{get_color_map, StyleComputer}; +use nu_protocol::{ + engine::{EngineState, Stack}, + Record, Value, }; +use ratatui::{layout::Rect, widgets::Block}; +use std::{borrow::Cow, collections::HashMap}; pub use self::tablew::Orientation; diff --git a/crates/nu-explore/src/views/record/tablew.rs b/crates/nu-explore/src/views/record/tablew.rs index 269f4f9d6ec2..d43a7943f647 100644 --- a/crates/nu-explore/src/views/record/tablew.rs +++ b/crates/nu-explore/src/views/record/tablew.rs @@ -1,8 +1,8 @@ -use std::{ - borrow::Cow, - cmp::{max, Ordering}, +use super::Layout; +use crate::{ + nu_common::{truncate_str, NuStyle, NuText}, + views::util::{nu_style_to_tui, text_style_to_tui_style}, }; - use nu_color_config::{Alignment, StyleComputer, TextStyle}; use nu_protocol::Value; use nu_table::string_width; @@ -12,14 +12,11 @@ use ratatui::{ text::Span, widgets::{Block, Borders, Paragraph, StatefulWidget, Widget}, }; - -use crate::{ - nu_common::{truncate_str, NuStyle, NuText}, - views::util::{nu_style_to_tui, text_style_to_tui_style}, +use std::{ + borrow::Cow, + cmp::{max, Ordering}, }; -use super::Layout; - #[derive(Debug, Clone)] pub struct TableW<'a> { columns: Cow<'a, [String]>, diff --git a/crates/nu-explore/src/views/util.rs b/crates/nu-explore/src/views/util.rs index d7f922312829..d6cef4b0f7ac 100644 --- a/crates/nu-explore/src/views/util.rs +++ b/crates/nu-explore/src/views/util.rs @@ -1,5 +1,4 @@ -use std::borrow::Cow; - +use crate::nu_common::{truncate_str, NuColor, NuStyle, NuText}; use nu_color_config::{Alignment, StyleComputer}; use nu_protocol::{ShellError, Value}; use nu_table::{string_width, TextStyle}; @@ -8,8 +7,7 @@ use ratatui::{ style::{Color, Modifier, Style}, text::Span, }; - -use crate::nu_common::{truncate_str, NuColor, NuStyle, NuText}; +use std::borrow::Cow; pub fn set_span( buf: &mut Buffer, diff --git a/crates/nu-lsp/src/diagnostics.rs b/crates/nu-lsp/src/diagnostics.rs index 78da89626666..a9bbab77a9a2 100644 --- a/crates/nu-lsp/src/diagnostics.rs +++ b/crates/nu-lsp/src/diagnostics.rs @@ -1,3 +1,4 @@ +use crate::LanguageServer; use lsp_types::{ notification::{Notification, PublishDiagnostics}, Diagnostic, DiagnosticSeverity, PublishDiagnosticsParams, Url, @@ -10,8 +11,6 @@ use nu_protocol::{ Span, Value, NU_VARIABLE_ID, }; -use crate::LanguageServer; - impl LanguageServer { pub(crate) fn publish_diagnostics_for_file( &self, diff --git a/crates/nu-lsp/src/lib.rs b/crates/nu-lsp/src/lib.rs index 27fc3f1f5814..6c347ff3d424 100644 --- a/crates/nu-lsp/src/lib.rs +++ b/crates/nu-lsp/src/lib.rs @@ -1,13 +1,3 @@ -use std::{ - collections::BTreeMap, - path::{Path, PathBuf}, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - time::Duration, -}; - use lsp_server::{Connection, IoThreads, Message, Response, ResponseError}; use lsp_types::{ request::{Completion, GotoDefinition, HoverRequest, Request}, @@ -24,6 +14,15 @@ use nu_protocol::{ DeclId, Span, Value, VarId, }; use ropey::Rope; +use std::{ + collections::BTreeMap, + path::{Path, PathBuf}, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, + time::Duration, +}; mod diagnostics; mod notification; diff --git a/crates/nu-parser/src/flatten.rs b/crates/nu-parser/src/flatten.rs index 26d3329c8e48..067052840dde 100644 --- a/crates/nu-parser/src/flatten.rs +++ b/crates/nu-parser/src/flatten.rs @@ -1,9 +1,11 @@ -use nu_protocol::ast::{ - Argument, Block, Expr, Expression, ExternalArgument, ImportPatternMember, MatchPattern, - PathMember, Pattern, Pipeline, PipelineElement, PipelineRedirection, RecordItem, +use nu_protocol::{ + ast::{ + Argument, Block, Expr, Expression, ExternalArgument, ImportPatternMember, MatchPattern, + PathMember, Pattern, Pipeline, PipelineElement, PipelineRedirection, RecordItem, + }, + engine::StateWorkingSet, + DeclId, Span, VarId, }; -use nu_protocol::{engine::StateWorkingSet, Span}; -use nu_protocol::{DeclId, VarId}; use std::fmt::{Display, Formatter, Result}; #[derive(Debug, Eq, PartialEq, Ord, Clone, PartialOrd)] diff --git a/crates/nu-parser/src/known_external.rs b/crates/nu-parser/src/known_external.rs index 600c3d985272..d5cc1f23699c 100644 --- a/crates/nu-parser/src/known_external.rs +++ b/crates/nu-parser/src/known_external.rs @@ -1,10 +1,5 @@ -use nu_protocol::engine::{EngineState, Stack}; -use nu_protocol::{ - ast::{Argument, Call, Expr, Expression}, - engine::Command, - ShellError, Signature, -}; -use nu_protocol::{PipelineData, Type}; +use nu_engine::command_prelude::*; +use nu_protocol::ast::{Argument, Expr, Expression}; #[derive(Clone)] pub struct KnownExternal { diff --git a/crates/nu-parser/src/lite_parser.rs b/crates/nu-parser/src/lite_parser.rs index 51b7f1e2ad0d..65bdc4763a0d 100644 --- a/crates/nu-parser/src/lite_parser.rs +++ b/crates/nu-parser/src/lite_parser.rs @@ -1,11 +1,9 @@ //! Lite parsing converts a flat stream of tokens from the lexer to a syntax element structure that //! can be parsed. -use std::mem; - use crate::{Token, TokenContents}; - use nu_protocol::{ast::RedirectionSource, ParseError, Span}; +use std::mem; #[derive(Debug, Clone, Copy)] pub enum LiteRedirectionTarget { diff --git a/crates/nu-parser/src/parse_keywords.rs b/crates/nu-parser/src/parse_keywords.rs index c2b7c7b21802..4bf247727282 100644 --- a/crates/nu-parser/src/parse_keywords.rs +++ b/crates/nu-parser/src/parse_keywords.rs @@ -18,9 +18,9 @@ use nu_protocol::{ span, Alias, BlockId, DeclId, Module, ModuleId, ParseError, PositionalArg, ResolvedImportPattern, Span, Spanned, SyntaxShape, Type, Value, VarId, }; -use std::path::{Path, PathBuf}; use std::{ collections::{HashMap, HashSet}, + path::{Path, PathBuf}, sync::Arc, }; diff --git a/crates/nu-parser/src/parse_patterns.rs b/crates/nu-parser/src/parse_patterns.rs index e93e22bae2c4..73668b7d04fa 100644 --- a/crates/nu-parser/src/parse_patterns.rs +++ b/crates/nu-parser/src/parse_patterns.rs @@ -1,14 +1,13 @@ +use crate::{ + lex, lite_parse, + parser::{is_variable, parse_value}, +}; use nu_protocol::{ ast::{MatchPattern, Pattern}, engine::StateWorkingSet, ParseError, Span, SyntaxShape, Type, VarId, }; -use crate::{ - lex, lite_parse, - parser::{is_variable, parse_value}, -}; - pub fn garbage(span: Span) -> MatchPattern { MatchPattern { pattern: Pattern::Garbage, diff --git a/crates/nu-parser/src/parse_shape_specs.rs b/crates/nu-parser/src/parse_shape_specs.rs index e07077d5b11d..2a59bb8a59fc 100644 --- a/crates/nu-parser/src/parse_shape_specs.rs +++ b/crates/nu-parser/src/parse_shape_specs.rs @@ -1,5 +1,4 @@ use crate::{lex::lex_signature, parser::parse_value, trim_quotes, TokenContents}; - use nu_protocol::{engine::StateWorkingSet, ParseError, Span, SyntaxShape, Type}; #[derive(Debug, Clone, Copy, PartialEq)] diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index b937252d47e4..22de0e060f49 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -1,41 +1,27 @@ use crate::{ lex::{lex, lex_signature}, lite_parser::{lite_parse, LiteCommand, LitePipeline, LiteRedirection, LiteRedirectionTarget}, + parse_keywords::*, parse_mut, parse_patterns::parse_pattern, parse_shape_specs::{parse_shape_name, parse_type, ShapeDescriptorUse}, type_check::{self, math_result_type, type_compatible}, Token, TokenContents, }; - +use itertools::Itertools; +use log::trace; use nu_engine::DIR_VAR_PARSER_INFO; use nu_protocol::{ - ast::{ - Argument, Assignment, Bits, Block, Boolean, Call, CellPath, Comparison, Expr, Expression, - ExternalArgument, FullCellPath, ImportPattern, ImportPatternHead, ImportPatternMember, - MatchPattern, Math, Operator, PathMember, Pattern, Pipeline, PipelineElement, - PipelineRedirection, RangeInclusion, RangeOperator, RecordItem, RedirectionTarget, - }, - engine::StateWorkingSet, - eval_const::eval_constant, - span, BlockId, DidYouMean, Flag, ParseError, PositionalArg, Signature, Span, Spanned, - SyntaxShape, Type, Unit, VarId, ENV_VARIABLE_ID, IN_VARIABLE_ID, -}; - -use crate::parse_keywords::{ - find_dirs_var, is_unaliasable_parser_keyword, parse_alias, parse_const, parse_def, - parse_def_predecl, parse_export_in_block, parse_extern, parse_for, parse_hide, parse_keyword, - parse_let, parse_module, parse_overlay_hide, parse_overlay_new, parse_overlay_use, - parse_source, parse_use, parse_where, parse_where_expr, LIB_DIRS_VAR, + ast::*, engine::StateWorkingSet, eval_const::eval_constant, span, BlockId, DidYouMean, Flag, + ParseError, PositionalArg, Signature, Span, Spanned, SyntaxShape, Type, Unit, VarId, + ENV_VARIABLE_ID, IN_VARIABLE_ID, }; - -use itertools::Itertools; -use log::trace; use std::{ collections::{HashMap, HashSet}, + num::ParseIntError, + str, sync::Arc, }; -use std::{num::ParseIntError, str}; #[cfg(feature = "plugin")] use crate::parse_keywords::parse_register; diff --git a/crates/nu-parser/src/parser_path.rs b/crates/nu-parser/src/parser_path.rs index fa60d1ecd21a..6d5cd7b3cf14 100644 --- a/crates/nu-parser/src/parser_path.rs +++ b/crates/nu-parser/src/parser_path.rs @@ -1,6 +1,8 @@ use nu_protocol::engine::{StateWorkingSet, VirtualPath}; -use std::ffi::OsStr; -use std::path::{Path, PathBuf}; +use std::{ + ffi::OsStr, + path::{Path, PathBuf}, +}; /// An abstraction over a PathBuf that can have virtual paths (files and directories). Virtual /// paths always exist and represent a way to ship Nushell code inside the binary without requiring diff --git a/crates/nu-parser/tests/test_parser.rs b/crates/nu-parser/tests/test_parser.rs index 44dfae5db57f..6c305c2971e3 100644 --- a/crates/nu-parser/tests/test_parser.rs +++ b/crates/nu-parser/tests/test_parser.rs @@ -1196,8 +1196,10 @@ mod range { #[cfg(test)] mod input_types { use super::*; - use nu_protocol::ast::Call; - use nu_protocol::{ast::Argument, Category, PipelineData, ShellError, Type}; + use nu_protocol::{ + ast::{Argument, Call}, + Category, PipelineData, ShellError, Type, + }; #[derive(Clone)] pub struct LsTest; diff --git a/crates/nu-plugin/src/plugin/context.rs b/crates/nu-plugin/src/plugin/context.rs index 58c550da7677..b366b3760562 100644 --- a/crates/nu-plugin/src/plugin/context.rs +++ b/crates/nu-plugin/src/plugin/context.rs @@ -1,17 +1,15 @@ -use std::{ - borrow::Cow, - collections::HashMap, - sync::{atomic::AtomicBool, Arc}, -}; - +use crate::util::MutableCow; use nu_engine::{get_eval_block_with_early_return, get_full_help}; use nu_protocol::{ ast::Call, engine::{Closure, EngineState, Redirection, Stack}, Config, IntoSpanned, IoStream, PipelineData, PluginIdentity, ShellError, Spanned, Value, }; - -use crate::util::MutableCow; +use std::{ + borrow::Cow, + collections::HashMap, + sync::{atomic::AtomicBool, Arc}, +}; /// Object safe trait for abstracting operations required of the plugin context. /// diff --git a/crates/nu-plugin/src/plugin/declaration.rs b/crates/nu-plugin/src/plugin/declaration.rs index 2936739cbb05..661930bc6db9 100644 --- a/crates/nu-plugin/src/plugin/declaration.rs +++ b/crates/nu-plugin/src/plugin/declaration.rs @@ -1,13 +1,9 @@ use super::{GetPlugin, PluginExecutionCommandContext, PluginSource}; use crate::protocol::{CallInfo, EvaluatedCall}; +use nu_engine::{command_prelude::*, get_eval_expression}; +use nu_protocol::{PluginIdentity, PluginSignature}; use std::sync::Arc; -use nu_engine::get_eval_expression; - -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ast::Call, PluginSignature, Signature}; -use nu_protocol::{Example, PipelineData, PluginIdentity, ShellError}; - #[doc(hidden)] // Note: not for plugin authors / only used in nu-parser #[derive(Clone)] pub struct PluginDeclaration { diff --git a/crates/nu-plugin/src/plugin/gc.rs b/crates/nu-plugin/src/plugin/gc.rs index a98fcf23c7eb..bd9c8de06f3c 100644 --- a/crates/nu-plugin/src/plugin/gc.rs +++ b/crates/nu-plugin/src/plugin/gc.rs @@ -1,13 +1,11 @@ +use crate::PersistentPlugin; +use nu_protocol::{PluginGcConfig, RegisteredPlugin}; use std::{ sync::{mpsc, Arc, Weak}, thread, time::{Duration, Instant}, }; -use nu_protocol::{PluginGcConfig, RegisteredPlugin}; - -use crate::PersistentPlugin; - /// Plugin garbage collector /// /// Many users don't want all of their plugins to stay running indefinitely after using them, so diff --git a/crates/nu-plugin/src/plugin/interface.rs b/crates/nu-plugin/src/plugin/interface.rs index f3c1bf8e3912..a200bc97036b 100644 --- a/crates/nu-plugin/src/plugin/interface.rs +++ b/crates/nu-plugin/src/plugin/interface.rs @@ -1,5 +1,13 @@ //! Implements the stream multiplexing interface for both the plugin side and the engine side. +use crate::{ + plugin::Encoder, + protocol::{ + ExternalStreamInfo, ListStreamInfo, PipelineDataHeader, RawStreamInfo, StreamMessage, + }, + sequence::Sequence, +}; +use nu_protocol::{ListStream, PipelineData, RawStream, ShellError}; use std::{ io::Write, sync::{ @@ -9,16 +17,6 @@ use std::{ thread, }; -use nu_protocol::{ListStream, PipelineData, RawStream, ShellError}; - -use crate::{ - plugin::Encoder, - protocol::{ - ExternalStreamInfo, ListStreamInfo, PipelineDataHeader, RawStreamInfo, StreamMessage, - }, - sequence::Sequence, -}; - mod stream; mod engine; diff --git a/crates/nu-plugin/src/plugin/interface/engine.rs b/crates/nu-plugin/src/plugin/interface/engine.rs index 397ccae03283..5791477939d2 100644 --- a/crates/nu-plugin/src/plugin/interface/engine.rs +++ b/crates/nu-plugin/src/plugin/interface/engine.rs @@ -1,29 +1,22 @@ //! Interface used by the plugin to communicate with the engine. -use std::{ - collections::{btree_map, BTreeMap, HashMap}, - sync::{mpsc, Arc}, +use super::{ + stream::{StreamManager, StreamManagerHandle}, + Interface, InterfaceManager, PipelineDataWriter, PluginRead, PluginWrite, Sequence, +}; +use crate::protocol::{ + CallInfo, CustomValueOp, EngineCall, EngineCallId, EngineCallResponse, Ordering, PluginCall, + PluginCallId, PluginCallResponse, PluginCustomValue, PluginInput, PluginOption, PluginOutput, + ProtocolInfo, }; - use nu_protocol::{ engine::Closure, Config, IntoInterruptiblePipelineData, LabeledError, ListStream, PipelineData, PluginSignature, ShellError, Spanned, Value, }; - -use crate::{ - protocol::{ - CallInfo, CustomValueOp, EngineCall, EngineCallId, EngineCallResponse, Ordering, - PluginCall, PluginCallId, PluginCallResponse, PluginCustomValue, PluginInput, PluginOption, - ProtocolInfo, - }, - PluginOutput, -}; - -use super::{ - stream::{StreamManager, StreamManagerHandle}, - Interface, InterfaceManager, PipelineDataWriter, PluginRead, PluginWrite, +use std::{ + collections::{btree_map, BTreeMap, HashMap}, + sync::{mpsc, Arc}, }; -use crate::sequence::Sequence; /// Plugin calls that are received by the [`EngineInterfaceManager`] for handling. /// diff --git a/crates/nu-plugin/src/plugin/interface/engine/tests.rs b/crates/nu-plugin/src/plugin/interface/engine/tests.rs index 6119ec77918b..e2f76811f7ed 100644 --- a/crates/nu-plugin/src/plugin/interface/engine/tests.rs +++ b/crates/nu-plugin/src/plugin/interface/engine/tests.rs @@ -1,13 +1,4 @@ -use std::{ - collections::HashMap, - sync::mpsc::{self, TryRecvError}, -}; - -use nu_protocol::{ - engine::Closure, Config, CustomValue, IntoInterruptiblePipelineData, LabeledError, - PipelineData, PluginExample, PluginSignature, ShellError, Span, Spanned, Value, -}; - +use super::{EngineInterfaceManager, ReceivedPluginCall}; use crate::{ plugin::interface::{test_util::TestCase, Interface, InterfaceManager}, protocol::{ @@ -18,8 +9,14 @@ use crate::{ }, EvaluatedCall, PluginCallResponse, PluginOutput, }; - -use super::{EngineInterfaceManager, ReceivedPluginCall}; +use nu_protocol::{ + engine::Closure, Config, CustomValue, IntoInterruptiblePipelineData, LabeledError, + PipelineData, PluginExample, PluginSignature, ShellError, Span, Spanned, Value, +}; +use std::{ + collections::HashMap, + sync::mpsc::{self, TryRecvError}, +}; #[test] fn manager_consume_all_consumes_messages() -> Result<(), ShellError> { diff --git a/crates/nu-plugin/src/plugin/interface/plugin.rs b/crates/nu-plugin/src/plugin/interface/plugin.rs index 1829edda8dc3..bf8b1b44fdfb 100644 --- a/crates/nu-plugin/src/plugin/interface/plugin.rs +++ b/crates/nu-plugin/src/plugin/interface/plugin.rs @@ -1,15 +1,9 @@ //! Interface used by the engine to communicate with the plugin. -use std::{ - collections::{btree_map, BTreeMap}, - sync::{atomic::AtomicBool, mpsc, Arc, OnceLock}, -}; - -use nu_protocol::{ - ast::Operator, IntoInterruptiblePipelineData, IntoSpanned, ListStream, PipelineData, - PluginSignature, ShellError, Span, Spanned, Value, +use super::{ + stream::{StreamManager, StreamManagerHandle}, + Interface, InterfaceManager, PipelineDataWriter, PluginRead, PluginWrite, }; - use crate::{ plugin::{context::PluginExecutionContext, gc::PluginGc, PluginSource}, protocol::{ @@ -19,10 +13,13 @@ use crate::{ }, sequence::Sequence, }; - -use super::{ - stream::{StreamManager, StreamManagerHandle}, - Interface, InterfaceManager, PipelineDataWriter, PluginRead, PluginWrite, +use nu_protocol::{ + ast::Operator, IntoInterruptiblePipelineData, IntoSpanned, ListStream, PipelineData, + PluginSignature, ShellError, Span, Spanned, Value, +}; +use std::{ + collections::{btree_map, BTreeMap}, + sync::{atomic::AtomicBool, mpsc, Arc, OnceLock}, }; #[cfg(test)] diff --git a/crates/nu-plugin/src/plugin/interface/plugin/tests.rs b/crates/nu-plugin/src/plugin/interface/plugin/tests.rs index 83eb2ccea8b2..2a25c8e50b50 100644 --- a/crates/nu-plugin/src/plugin/interface/plugin/tests.rs +++ b/crates/nu-plugin/src/plugin/interface/plugin/tests.rs @@ -1,10 +1,6 @@ -use std::{sync::mpsc, time::Duration}; - -use nu_protocol::{ - engine::Closure, IntoInterruptiblePipelineData, PipelineData, PluginSignature, ShellError, - Span, Spanned, Value, +use super::{ + Context, PluginCallState, PluginInterface, PluginInterfaceManager, ReceivedPluginCallMessage, }; - use crate::{ plugin::{ context::PluginExecutionBogusContext, @@ -19,10 +15,11 @@ use crate::{ }, EvaluatedCall, PluginCallResponse, PluginOutput, }; - -use super::{ - Context, PluginCallState, PluginInterface, PluginInterfaceManager, ReceivedPluginCallMessage, +use nu_protocol::{ + engine::Closure, IntoInterruptiblePipelineData, PipelineData, PluginSignature, ShellError, + Span, Spanned, Value, }; +use std::{sync::mpsc, time::Duration}; #[test] fn manager_consume_all_consumes_messages() -> Result<(), ShellError> { diff --git a/crates/nu-plugin/src/plugin/interface/stream.rs b/crates/nu-plugin/src/plugin/interface/stream.rs index ca1e87c54ff2..86ac15d6f967 100644 --- a/crates/nu-plugin/src/plugin/interface/stream.rs +++ b/crates/nu-plugin/src/plugin/interface/stream.rs @@ -1,3 +1,5 @@ +use crate::protocol::{StreamData, StreamId, StreamMessage}; +use nu_protocol::{ShellError, Span, Value}; use std::{ collections::{btree_map, BTreeMap}, iter::FusedIterator, @@ -5,10 +7,6 @@ use std::{ sync::{mpsc, Arc, Condvar, Mutex, MutexGuard, Weak}, }; -use nu_protocol::{ShellError, Span, Value}; - -use crate::protocol::{StreamData, StreamId, StreamMessage}; - #[cfg(test)] mod tests; diff --git a/crates/nu-plugin/src/plugin/interface/stream/tests.rs b/crates/nu-plugin/src/plugin/interface/stream/tests.rs index b8b301aa086a..ecdb561b9a48 100644 --- a/crates/nu-plugin/src/plugin/interface/stream/tests.rs +++ b/crates/nu-plugin/src/plugin/interface/stream/tests.rs @@ -6,11 +6,9 @@ use std::{ time::{Duration, Instant}, }; -use nu_protocol::{ShellError, Value}; - -use crate::protocol::{StreamData, StreamMessage}; - use super::{StreamManager, StreamReader, StreamWriter, StreamWriterSignal, WriteStreamMessage}; +use crate::protocol::{StreamData, StreamMessage}; +use nu_protocol::{ShellError, Value}; // Should be long enough to definitely complete any quick operation, but not so long that tests are // slow to complete. 10 ms is a pretty long time diff --git a/crates/nu-plugin/src/plugin/interface/test_util.rs b/crates/nu-plugin/src/plugin/interface/test_util.rs index 47836aa48575..b701ff779270 100644 --- a/crates/nu-plugin/src/plugin/interface/test_util.rs +++ b/crates/nu-plugin/src/plugin/interface/test_util.rs @@ -1,14 +1,11 @@ +use super::{EngineInterfaceManager, PluginInterfaceManager, PluginRead, PluginWrite}; +use crate::{plugin::PluginSource, protocol::PluginInput, PluginOutput}; +use nu_protocol::ShellError; use std::{ collections::VecDeque, sync::{Arc, Mutex}, }; -use nu_protocol::ShellError; - -use crate::{plugin::PluginSource, protocol::PluginInput, PluginOutput}; - -use super::{EngineInterfaceManager, PluginInterfaceManager, PluginRead, PluginWrite}; - /// Mock read/write helper for the engine and plugin interfaces. #[derive(Debug, Clone)] pub(crate) struct TestCase { diff --git a/crates/nu-plugin/src/plugin/interface/tests.rs b/crates/nu-plugin/src/plugin/interface/tests.rs index 707a0d7cc313..d92a152e0315 100644 --- a/crates/nu-plugin/src/plugin/interface/tests.rs +++ b/crates/nu-plugin/src/plugin/interface/tests.rs @@ -1,9 +1,8 @@ -use std::{path::Path, sync::Arc}; - -use nu_protocol::{ - DataSource, ListStream, PipelineData, PipelineMetadata, RawStream, ShellError, Span, Value, +use super::{ + stream::{StreamManager, StreamManagerHandle}, + test_util::TestCase, + Interface, InterfaceManager, PluginRead, PluginWrite, }; - use crate::{ protocol::{ ExternalStreamInfo, ListStreamInfo, PipelineDataHeader, PluginInput, PluginOutput, @@ -11,12 +10,10 @@ use crate::{ }, sequence::Sequence, }; - -use super::{ - stream::{StreamManager, StreamManagerHandle}, - test_util::TestCase, - Interface, InterfaceManager, PluginRead, PluginWrite, +use nu_protocol::{ + DataSource, ListStream, PipelineData, PipelineMetadata, RawStream, ShellError, Span, Value, }; +use std::{path::Path, sync::Arc}; fn test_metadata() -> PipelineMetadata { PipelineMetadata { diff --git a/crates/nu-plugin/src/plugin/mod.rs b/crates/nu-plugin/src/plugin/mod.rs index 9bb9dffb77b4..9bea8dc5f13d 100644 --- a/crates/nu-plugin/src/plugin/mod.rs +++ b/crates/nu-plugin/src/plugin/mod.rs @@ -1,33 +1,31 @@ +use crate::{ + plugin::interface::ReceivedPluginCall, + protocol::{CallInfo, CustomValueOp, PluginCustomValue, PluginInput, PluginOutput}, + EncodingType, +}; use nu_engine::documentation::get_flags_section; -use nu_protocol::LabeledError; -use thiserror::Error; - -use std::cmp::Ordering; -use std::collections::HashMap; -use std::ffi::OsStr; -use std::fmt::Write; -use std::io::{BufReader, Read, Write as WriteTrait}; -use std::path::Path; -use std::process::{Child, ChildStdout, Command as CommandSys, Stdio}; -use std::{env, thread}; - -use std::sync::mpsc::TrySendError; -use std::sync::{mpsc, Arc, Mutex}; - -use crate::plugin::interface::ReceivedPluginCall; -use crate::protocol::{CallInfo, CustomValueOp, PluginCustomValue, PluginInput, PluginOutput}; -use crate::EncodingType; - +use nu_protocol::{ + ast::Operator, CustomValue, IntoSpanned, LabeledError, PipelineData, PluginSignature, + ShellError, Spanned, Value, +}; #[cfg(unix)] use std::os::unix::process::CommandExt; - #[cfg(windows)] use std::os::windows::process::CommandExt; - -use nu_protocol::{ - ast::Operator, CustomValue, IntoSpanned, PipelineData, PluginSignature, ShellError, Spanned, - Value, +use std::{ + cmp::Ordering, + collections::HashMap, + env, + ffi::OsStr, + fmt::Write, + io::{BufReader, Read, Write as WriteTrait}, + path::Path, + process::{Child, ChildStdout, Command as CommandSys, Stdio}, + sync::mpsc::TrySendError, + sync::{mpsc, Arc, Mutex}, + thread, }; +use thiserror::Error; use self::gc::PluginGc; pub use self::interface::{PluginRead, PluginWrite}; diff --git a/crates/nu-plugin/src/plugin/persistent.rs b/crates/nu-plugin/src/plugin/persistent.rs index 574126b25676..a2f3cf07334c 100644 --- a/crates/nu-plugin/src/plugin/persistent.rs +++ b/crates/nu-plugin/src/plugin/persistent.rs @@ -1,14 +1,12 @@ -use std::{ - ffi::OsStr, - sync::{Arc, Mutex}, -}; - +use super::{create_command, gc::PluginGc, make_plugin_interface, PluginInterface, PluginSource}; use nu_protocol::{ engine::{EngineState, Stack}, PluginGcConfig, PluginIdentity, RegisteredPlugin, ShellError, }; - -use super::{create_command, gc::PluginGc, make_plugin_interface, PluginInterface, PluginSource}; +use std::{ + ffi::OsStr, + sync::{Arc, Mutex}, +}; /// A box that can keep a plugin that was spawned persistent for further uses. The plugin may or /// may not be currently running. [`.get()`] gets the currently running plugin, or spawns it if it's diff --git a/crates/nu-plugin/src/plugin/source.rs b/crates/nu-plugin/src/plugin/source.rs index 59b23d2e0753..4a10a7ed8363 100644 --- a/crates/nu-plugin/src/plugin/source.rs +++ b/crates/nu-plugin/src/plugin/source.rs @@ -1,8 +1,6 @@ -use std::sync::{Arc, Weak}; - -use nu_protocol::{PluginIdentity, ShellError, Span}; - use super::GetPlugin; +use nu_protocol::{PluginIdentity, ShellError, Span}; +use std::sync::{Arc, Weak}; /// The source of a custom value or plugin command. Includes a weak reference to the persistent /// plugin so it can be retrieved. diff --git a/crates/nu-plugin/src/protocol/evaluated_call.rs b/crates/nu-plugin/src/protocol/evaluated_call.rs index 5f96aeba5890..f2f0ebbda641 100644 --- a/crates/nu-plugin/src/protocol/evaluated_call.rs +++ b/crates/nu-plugin/src/protocol/evaluated_call.rs @@ -1,7 +1,5 @@ -use nu_protocol::ast::Expression; - use nu_protocol::{ - ast::Call, + ast::{Call, Expression}, engine::{EngineState, Stack}, FromValue, ShellError, Span, Spanned, Value, }; diff --git a/crates/nu-plugin/src/protocol/mod.rs b/crates/nu-plugin/src/protocol/mod.rs index 35895ca04c6a..5f2a9b85105a 100644 --- a/crates/nu-plugin/src/protocol/mod.rs +++ b/crates/nu-plugin/src/protocol/mod.rs @@ -8,18 +8,18 @@ mod tests; #[cfg(test)] pub(crate) mod test_util; -use std::collections::HashMap; - -pub use evaluated_call::EvaluatedCall; use nu_protocol::{ ast::Operator, engine::Closure, Config, LabeledError, PipelineData, PluginSignature, RawStream, ShellError, Span, Spanned, Value, }; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +pub use evaluated_call::EvaluatedCall; pub use plugin_custom_value::PluginCustomValue; #[cfg(test)] pub use protocol_info::Protocol; pub use protocol_info::ProtocolInfo; -use serde::{Deserialize, Serialize}; /// A sequential identifier for a stream pub type StreamId = usize; diff --git a/crates/nu-plugin/src/protocol/plugin_custom_value.rs b/crates/nu-plugin/src/protocol/plugin_custom_value.rs index 277ede68143d..445c9bd578b3 100644 --- a/crates/nu-plugin/src/protocol/plugin_custom_value.rs +++ b/crates/nu-plugin/src/protocol/plugin_custom_value.rs @@ -1,9 +1,7 @@ -use std::{cmp::Ordering, convert::Infallible, sync::Arc}; - +use crate::plugin::{PluginInterface, PluginSource}; use nu_protocol::{ast::Operator, CustomValue, IntoSpanned, ShellError, Span, Value}; use serde::{Deserialize, Serialize}; - -use crate::plugin::{PluginInterface, PluginSource}; +use std::{cmp::Ordering, convert::Infallible, sync::Arc}; #[cfg(test)] mod tests; diff --git a/crates/nu-plugin/src/protocol/plugin_custom_value/tests.rs b/crates/nu-plugin/src/protocol/plugin_custom_value/tests.rs index 8475db77a5db..5ba533ad77ed 100644 --- a/crates/nu-plugin/src/protocol/plugin_custom_value/tests.rs +++ b/crates/nu-plugin/src/protocol/plugin_custom_value/tests.rs @@ -1,9 +1,4 @@ -use std::sync::Arc; - -use nu_protocol::{ - ast::RangeInclusion, engine::Closure, record, CustomValue, Range, ShellError, Span, Value, -}; - +use super::PluginCustomValue; use crate::{ plugin::PluginSource, protocol::test_util::{ @@ -11,8 +6,10 @@ use crate::{ TestCustomValue, }, }; - -use super::PluginCustomValue; +use nu_protocol::{ + ast::RangeInclusion, engine::Closure, record, CustomValue, Range, ShellError, Span, Value, +}; +use std::sync::Arc; #[test] fn serialize_deserialize() -> Result<(), ShellError> { diff --git a/crates/nu-plugin/src/protocol/test_util.rs b/crates/nu-plugin/src/protocol/test_util.rs index 53c2f8699276..293326538edf 100644 --- a/crates/nu-plugin/src/protocol/test_util.rs +++ b/crates/nu-plugin/src/protocol/test_util.rs @@ -1,10 +1,8 @@ +use super::PluginCustomValue; +use crate::plugin::PluginSource; use nu_protocol::{CustomValue, ShellError, Span, Value}; use serde::{Deserialize, Serialize}; -use crate::plugin::PluginSource; - -use super::PluginCustomValue; - #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub(crate) struct TestCustomValue(pub i32); diff --git a/crates/nu-plugin/src/sequence.rs b/crates/nu-plugin/src/sequence.rs index c27e2a1e3137..65308d2e684b 100644 --- a/crates/nu-plugin/src/sequence.rs +++ b/crates/nu-plugin/src/sequence.rs @@ -1,6 +1,5 @@ -use std::sync::atomic::{AtomicUsize, Ordering::Relaxed}; - use nu_protocol::ShellError; +use std::sync::atomic::{AtomicUsize, Ordering::Relaxed}; /// Implements an atomically incrementing sequential series of numbers #[derive(Debug, Default)] diff --git a/crates/nu-protocol/src/ast/expression.rs b/crates/nu-protocol/src/ast/expression.rs index ca70e79ff9d6..70e5e5180478 100644 --- a/crates/nu-protocol/src/ast/expression.rs +++ b/crates/nu-protocol/src/ast/expression.rs @@ -1,11 +1,10 @@ -use std::sync::Arc; - +use crate::{ + ast::{Argument, Block, Expr, ExternalArgument, ImportPattern, RecordItem}, + engine::StateWorkingSet, + BlockId, DeclId, Signature, Span, Type, VarId, IN_VARIABLE_ID, +}; use serde::{Deserialize, Serialize}; - -use super::{Argument, Block, Expr, ExternalArgument, RecordItem}; -use crate::ast::ImportPattern; -use crate::DeclId; -use crate::{engine::StateWorkingSet, BlockId, Signature, Span, Type, VarId, IN_VARIABLE_ID}; +use std::sync::Arc; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Expression { diff --git a/crates/nu-protocol/src/config/hooks.rs b/crates/nu-protocol/src/config/hooks.rs index 4bef3e5e6d87..88f5f4abf1a4 100644 --- a/crates/nu-protocol/src/config/hooks.rs +++ b/crates/nu-protocol/src/config/hooks.rs @@ -1,5 +1,6 @@ use crate::{Config, Record, ShellError, Span, Value}; use serde::{Deserialize, Serialize}; + /// Definition of a parsed hook from the config object #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Hooks { diff --git a/crates/nu-protocol/src/debugger/debugger_trait.rs b/crates/nu-protocol/src/debugger/debugger_trait.rs index 9a003971483a..7a842f6c280b 100644 --- a/crates/nu-protocol/src/debugger/debugger_trait.rs +++ b/crates/nu-protocol/src/debugger/debugger_trait.rs @@ -13,11 +13,12 @@ //! (`NoopDebugger` is placed in its place inside `EngineState`.) After deactivating, you can call //! `Debugger::report()` to get some output from the debugger, if necessary. -use crate::ast::{Block, PipelineElement}; -use crate::engine::EngineState; -use crate::{PipelineData, ShellError, Span, Value}; -use std::fmt::Debug; -use std::ops::DerefMut; +use crate::{ + ast::{Block, PipelineElement}, + engine::EngineState, + PipelineData, ShellError, Span, Value, +}; +use std::{fmt::Debug, ops::DerefMut}; /// Trait used for static dispatch of `eval_xxx()` evaluator calls /// diff --git a/crates/nu-protocol/src/debugger/profiler.rs b/crates/nu-protocol/src/debugger/profiler.rs index 68a5e8ea97f9..a76c027e1433 100644 --- a/crates/nu-protocol/src/debugger/profiler.rs +++ b/crates/nu-protocol/src/debugger/profiler.rs @@ -3,11 +3,12 @@ //! Profiler implements the Debugger trait and can be used via the `debug profile` command for //! profiling Nushell code. -use crate::ast::{Block, Expr, PipelineElement}; -use crate::debugger::Debugger; -use crate::engine::EngineState; -use crate::record; -use crate::{PipelineData, ShellError, Span, Value}; +use crate::{ + ast::{Block, Expr, PipelineElement}, + debugger::Debugger, + engine::EngineState, + record, PipelineData, ShellError, Span, Value, +}; use std::time::Instant; #[derive(Debug, Clone, Copy)] diff --git a/crates/nu-protocol/src/engine/call_info.rs b/crates/nu-protocol/src/engine/call_info.rs index a30dc2d84863..36455243e585 100644 --- a/crates/nu-protocol/src/engine/call_info.rs +++ b/crates/nu-protocol/src/engine/call_info.rs @@ -1,5 +1,4 @@ -use crate::ast::Call; -use crate::Span; +use crate::{ast::Call, Span}; #[derive(Debug, Clone)] pub struct UnevaluatedCallInfo { diff --git a/crates/nu-protocol/src/engine/engine_state.rs b/crates/nu-protocol/src/engine/engine_state.rs index a2271e900abe..5ff56c3f1ac1 100644 --- a/crates/nu-protocol/src/engine/engine_state.rs +++ b/crates/nu-protocol/src/engine/engine_state.rs @@ -1,27 +1,24 @@ -use fancy_regex::Regex; -use lru::LruCache; - -use super::cached_file::CachedFile; -use super::{usage::build_usage, usage::Usage, StateDelta}; -use super::{ - Command, CommandType, EnvVars, OverlayFrame, ScopeFrame, Stack, Variable, Visibility, - DEFAULT_OVERLAY_NAME, -}; -use crate::ast::Block; -use crate::debugger::{Debugger, NoopDebugger}; use crate::{ - BlockId, Config, DeclId, Example, FileId, HistoryConfig, Module, ModuleId, OverlayId, - ShellError, Signature, Span, Type, VarId, VirtualPathId, + ast::Block, + debugger::{Debugger, NoopDebugger}, + engine::{ + usage::{build_usage, Usage}, + CachedFile, Command, CommandType, EnvVars, OverlayFrame, ScopeFrame, Stack, StateDelta, + Variable, Visibility, DEFAULT_OVERLAY_NAME, + }, + BlockId, Category, Config, DeclId, Example, FileId, HistoryConfig, Module, ModuleId, OverlayId, + ShellError, Signature, Span, Type, Value, VarId, VirtualPathId, }; -use crate::{Category, Value}; -use std::collections::HashMap; -use std::num::NonZeroUsize; -use std::path::Path; -use std::path::PathBuf; -use std::sync::atomic::Ordering; -use std::sync::{ - atomic::{AtomicBool, AtomicU32}, - Arc, Mutex, MutexGuard, PoisonError, +use fancy_regex::Regex; +use lru::LruCache; +use std::{ + collections::HashMap, + num::NonZeroUsize, + path::{Path, PathBuf}, + sync::{ + atomic::{AtomicBool, AtomicU32, Ordering}, + Arc, Mutex, MutexGuard, PoisonError, + }, }; type PoisonDebuggerError<'a> = PoisonError>>; diff --git a/crates/nu-protocol/src/engine/stack.rs b/crates/nu-protocol/src/engine/stack.rs index 4b4d4a1b31ca..e243ee059f5c 100644 --- a/crates/nu-protocol/src/engine/stack.rs +++ b/crates/nu-protocol/src/engine/stack.rs @@ -1,12 +1,14 @@ -use std::collections::{HashMap, HashSet}; -use std::sync::Arc; - use crate::{ - engine::{EngineState, DEFAULT_OVERLAY_NAME}, + engine::{ + EngineState, Redirection, StackCallArgGuard, StackCaptureGuard, StackIoGuard, StackStdio, + DEFAULT_OVERLAY_NAME, + }, IoStream, ShellError, Span, Value, VarId, ENV_VARIABLE_ID, NU_VARIABLE_ID, }; - -use super::{Redirection, StackCallArgGuard, StackCaptureGuard, StackIoGuard, StackStdio}; +use std::{ + collections::{HashMap, HashSet}, + sync::Arc, +}; /// Environment variables per overlay pub type EnvVars = HashMap>; diff --git a/crates/nu-protocol/src/engine/state_delta.rs b/crates/nu-protocol/src/engine/state_delta.rs index c7df18c8906c..3cfc4384ee61 100644 --- a/crates/nu-protocol/src/engine/state_delta.rs +++ b/crates/nu-protocol/src/engine/state_delta.rs @@ -1,8 +1,11 @@ -use super::cached_file::CachedFile; -use super::{usage::Usage, Command, EngineState, OverlayFrame, ScopeFrame, Variable, VirtualPath}; -use crate::ast::Block; -use crate::Module; - +use crate::{ + ast::Block, + engine::{ + usage::Usage, CachedFile, Command, EngineState, OverlayFrame, ScopeFrame, Variable, + VirtualPath, + }, + Module, +}; use std::sync::Arc; #[cfg(feature = "plugin")] diff --git a/crates/nu-protocol/src/engine/state_working_set.rs b/crates/nu-protocol/src/engine/state_working_set.rs index 999c7d793843..b784b042c619 100644 --- a/crates/nu-protocol/src/engine/state_working_set.rs +++ b/crates/nu-protocol/src/engine/state_working_set.rs @@ -1,17 +1,18 @@ -use super::cached_file::CachedFile; -use super::CommandType; -use super::{ - usage::build_usage, Command, EngineState, OverlayFrame, StateDelta, Variable, VirtualPath, - Visibility, PWD_ENV, +use crate::{ + ast::Block, + engine::{ + usage::build_usage, CachedFile, Command, CommandType, EngineState, OverlayFrame, + StateDelta, Variable, VirtualPath, Visibility, PWD_ENV, + }, + BlockId, Category, Config, DeclId, FileId, Module, ModuleId, ParseError, ParseWarning, Span, + Type, Value, VarId, VirtualPathId, }; -use crate::ast::Block; -use crate::{BlockId, Config, DeclId, FileId, Module, ModuleId, Span, Type, VarId, VirtualPathId}; -use crate::{Category, ParseError, ParseWarning, Value}; use core::panic; -use std::collections::{HashMap, HashSet}; -use std::path::PathBuf; - -use std::sync::Arc; +use std::{ + collections::{HashMap, HashSet}, + path::PathBuf, + sync::Arc, +}; #[cfg(feature = "plugin")] use crate::{PluginIdentity, RegisteredPlugin}; diff --git a/crates/nu-protocol/src/engine/stdio.rs b/crates/nu-protocol/src/engine/stdio.rs index ba8a3d045909..8cdafa3958e3 100644 --- a/crates/nu-protocol/src/engine/stdio.rs +++ b/crates/nu-protocol/src/engine/stdio.rs @@ -1,3 +1,4 @@ +use crate::{engine::Stack, IoStream}; use std::{ fs::File, mem, @@ -5,10 +6,6 @@ use std::{ sync::Arc, }; -use crate::IoStream; - -use super::Stack; - #[derive(Debug, Clone)] pub enum Redirection { /// A pipe redirection. diff --git a/crates/nu-protocol/src/eval_base.rs b/crates/nu-protocol/src/eval_base.rs index 6650c7f6bfcb..01955217f1b9 100644 --- a/crates/nu-protocol/src/eval_base.rs +++ b/crates/nu-protocol/src/eval_base.rs @@ -1,12 +1,11 @@ -use crate::debugger::DebugContext; use crate::{ ast::{ eval_operator, Assignment, Bits, Boolean, Call, Comparison, Expr, Expression, ExternalArgument, Math, Operator, RecordItem, }, + debugger::DebugContext, Config, IntoInterruptiblePipelineData, Range, Record, ShellError, Span, Value, VarId, }; - use std::{borrow::Cow, collections::HashMap}; /// To share implementations for regular eval and const eval diff --git a/crates/nu-protocol/src/eval_const.rs b/crates/nu-protocol/src/eval_const.rs index cc2b219df4c2..724a1c0841f1 100644 --- a/crates/nu-protocol/src/eval_const.rs +++ b/crates/nu-protocol/src/eval_const.rs @@ -1,13 +1,15 @@ -use crate::debugger::{DebugContext, WithoutDebug}; use crate::{ ast::{Assignment, Block, Call, Expr, Expression, ExternalArgument}, + debugger::{DebugContext, WithoutDebug}, engine::{EngineState, StateWorkingSet}, eval_base::Eval, record, Config, HistoryFileFormat, PipelineData, Record, ShellError, Span, Value, VarId, }; use nu_system::os_info::{get_kernel_version, get_os_arch, get_os_family, get_os_name}; -use std::borrow::Cow; -use std::path::{Path, PathBuf}; +use std::{ + borrow::Cow, + path::{Path, PathBuf}, +}; pub fn create_nu_constant(engine_state: &EngineState, span: Span) -> Result { fn canonicalize_path(engine_state: &EngineState, path: &Path) -> PathBuf { diff --git a/crates/nu-protocol/src/pipeline_data/mod.rs b/crates/nu-protocol/src/pipeline_data/mod.rs index 857cab36ede6..f601292fd52d 100644 --- a/crates/nu-protocol/src/pipeline_data/mod.rs +++ b/crates/nu-protocol/src/pipeline_data/mod.rs @@ -12,9 +12,11 @@ use crate::{ format_error, Config, ShellError, Span, Value, }; use nu_utils::{stderr_write_all_and_flush, stdout_write_all_and_flush}; -use std::io::{self, Cursor, Read, Write}; -use std::sync::{atomic::AtomicBool, Arc}; -use std::thread; +use std::{ + io::{self, Cursor, Read, Write}, + sync::{atomic::AtomicBool, Arc}, + thread, +}; const LINE_ENDING_PATTERN: &[char] = &['\r', '\n']; diff --git a/crates/nu-protocol/src/plugin/signature.rs b/crates/nu-protocol/src/plugin/signature.rs index 075d4d19e5b0..d92736abdfc4 100644 --- a/crates/nu-protocol/src/plugin/signature.rs +++ b/crates/nu-protocol/src/plugin/signature.rs @@ -1,9 +1,8 @@ -use crate::{PluginExample, Signature}; -use serde::Deserialize; -use serde::Serialize; - -use crate::engine::Command; -use crate::{BlockId, Category, Flag, PositionalArg, SyntaxShape, Type}; +use crate::{ + engine::Command, BlockId, Category, Flag, PluginExample, PositionalArg, Signature, SyntaxShape, + Type, +}; +use serde::{Deserialize, Serialize}; /// A simple wrapper for Signature that includes examples. #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/crates/nu-protocol/src/signature.rs b/crates/nu-protocol/src/signature.rs index f5acadc7daf0..05949f36d879 100644 --- a/crates/nu-protocol/src/signature.rs +++ b/crates/nu-protocol/src/signature.rs @@ -1,17 +1,9 @@ -use serde::Deserialize; -use serde::Serialize; - -use crate::ast::Call; -use crate::engine::Command; -use crate::engine::EngineState; -use crate::engine::Stack; -use crate::BlockId; -use crate::PipelineData; -use crate::ShellError; -use crate::SyntaxShape; -use crate::Type; -use crate::Value; -use crate::VarId; +use crate::{ + ast::Call, + engine::{Command, EngineState, Stack}, + BlockId, PipelineData, ShellError, SyntaxShape, Type, Value, VarId, +}; +use serde::{Deserialize, Serialize}; use std::fmt::Write; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] diff --git a/crates/nu-protocol/src/value/from_value.rs b/crates/nu-protocol/src/value/from_value.rs index 79df03d808a1..baa77ad7eabf 100644 --- a/crates/nu-protocol/src/value/from_value.rs +++ b/crates/nu-protocol/src/value/from_value.rs @@ -1,10 +1,10 @@ -use std::path::PathBuf; - -use super::NuGlob; -use crate::ast::{CellPath, PathMember}; -use crate::engine::{Block, Closure}; -use crate::{Range, Record, ShellError, Spanned, Value}; +use crate::{ + ast::{CellPath, PathMember}, + engine::{Block, Closure}, + NuGlob, Range, Record, ShellError, Spanned, Value, +}; use chrono::{DateTime, FixedOffset}; +use std::path::PathBuf; pub trait FromValue: Sized { fn from_value(v: Value) -> Result; diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index e60aa5506ec9..7ba0762bee96 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -17,23 +17,26 @@ pub use lazy_record::LazyRecord; pub use range::*; pub use record::Record; -use crate::ast::{Bits, Boolean, CellPath, Comparison, Math, Operator, PathMember, RangeInclusion}; -use crate::engine::{Closure, EngineState}; -use crate::{did_you_mean, BlockId, Config, ShellError, Span, Type}; - +use crate::{ + ast::{Bits, Boolean, CellPath, Comparison, Math, Operator, PathMember, RangeInclusion}, + did_you_mean, + engine::{Closure, EngineState}, + BlockId, Config, ShellError, Span, Type, +}; use chrono::{DateTime, Datelike, FixedOffset, Locale, TimeZone}; use chrono_humanize::HumanTime; use fancy_regex::Regex; -use nu_utils::locale::LOCALE_OVERRIDE_ENV_VAR; -use nu_utils::{contains_emoji, locale::get_system_locale_string, IgnoreCaseExt}; +use nu_utils::{ + contains_emoji, + locale::{get_system_locale_string, LOCALE_OVERRIDE_ENV_VAR}, + IgnoreCaseExt, +}; use serde::{Deserialize, Serialize}; -use std::fmt::Write; - use std::{ borrow::Cow, - fmt::Display, + cmp::Ordering, + fmt::{Debug, Display, Write}, path::PathBuf, - {cmp::Ordering, fmt::Debug}, }; /// Core structured values that pass through the pipeline in Nushell. diff --git a/crates/nu-std/src/lib.rs b/crates/nu-std/src/lib.rs index c90a2cd7b1dc..93c0523ce600 100644 --- a/crates/nu-std/src/lib.rs +++ b/crates/nu-std/src/lib.rs @@ -1,10 +1,11 @@ -use std::path::PathBuf; - use nu_engine::{env::current_dir, eval_block}; use nu_parser::parse; -use nu_protocol::debugger::WithoutDebug; -use nu_protocol::engine::{Stack, StateWorkingSet, VirtualPath}; -use nu_protocol::{report_error, PipelineData}; +use nu_protocol::{ + debugger::WithoutDebug, + engine::{Stack, StateWorkingSet, VirtualPath}, + report_error, PipelineData, +}; +use std::path::PathBuf; // Virtual std directory unlikely to appear in user's file system const NU_STDLIB_VIRTUAL_DIR: &str = "NU_STDLIB_VIRTUAL_DIR"; diff --git a/crates/nu-table/src/common.rs b/crates/nu-table/src/common.rs index 67095b5c7957..76cd8adf523b 100644 --- a/crates/nu-table/src/common.rs +++ b/crates/nu-table/src/common.rs @@ -1,10 +1,8 @@ -use nu_color_config::{Alignment, StyleComputer, TextStyle}; -use nu_protocol::{Config, FooterMode, ShellError, Span, Value}; -use nu_protocol::{TableMode, TrimStrategy}; - use crate::{ clean_charset, colorize_space_str, string_wrap, NuTableConfig, TableOutput, TableTheme, }; +use nu_color_config::{Alignment, StyleComputer, TextStyle}; +use nu_protocol::{Config, FooterMode, ShellError, Span, TableMode, TrimStrategy, Value}; pub type NuText = (String, TextStyle); pub type TableResult = Result, ShellError>; diff --git a/crates/nu-table/src/table.rs b/crates/nu-table/src/table.rs index 0c8754fec034..461ec247f68e 100644 --- a/crates/nu-table/src/table.rs +++ b/crates/nu-table/src/table.rs @@ -3,8 +3,7 @@ use nu_ansi_term::Style; use nu_color_config::TextStyle; use nu_protocol::TrimStrategy; use nu_utils::strip_ansi_unlikely; -use std::cmp::min; -use std::collections::HashMap; +use std::{cmp::min, collections::HashMap}; use tabled::{ builder::Builder, grid::{ diff --git a/crates/nu-table/src/types/collapse.rs b/crates/nu-table/src/types/collapse.rs index f8e34c79a49b..d4d43e86a924 100644 --- a/crates/nu-table/src/types/collapse.rs +++ b/crates/nu-table/src/types/collapse.rs @@ -1,13 +1,9 @@ -use nu_color_config::StyleComputer; -use nu_protocol::{Config, Record, TableMode, Value}; - -use crate::UnstructuredTable; - -use crate::common::nu_value_to_string_clean; use crate::{ - common::{get_index_style, load_theme}, - StringResult, TableOpts, + common::{get_index_style, load_theme, nu_value_to_string_clean}, + StringResult, TableOpts, UnstructuredTable, }; +use nu_color_config::StyleComputer; +use nu_protocol::{Config, Record, TableMode, Value}; pub struct CollapsedTable; diff --git a/crates/nu-table/src/types/expanded.rs b/crates/nu-table/src/types/expanded.rs index 0be50eee5681..9472cc284651 100644 --- a/crates/nu-table/src/types/expanded.rs +++ b/crates/nu-table/src/types/expanded.rs @@ -1,11 +1,3 @@ -use std::cmp::max; -use std::collections::HashMap; - -use nu_color_config::{Alignment, StyleComputer, TextStyle}; -use nu_engine::column::get_columns; -use nu_protocol::{Config, Record, ShellError, Span, Value}; -use tabled::grid::config::Position; - use crate::{ common::{ create_nu_table_config, error_sign, get_header_style, get_index_style, load_theme, @@ -16,6 +8,11 @@ use crate::{ types::has_index, NuTable, NuTableCell, TableOpts, TableOutput, }; +use nu_color_config::{Alignment, StyleComputer, TextStyle}; +use nu_engine::column::get_columns; +use nu_protocol::{Config, Record, ShellError, Span, Value}; +use std::{cmp::max, collections::HashMap}; +use tabled::grid::config::Position; #[derive(Debug, Clone)] pub struct ExpandedTable { diff --git a/crates/nu-table/src/types/general.rs b/crates/nu-table/src/types/general.rs index c74b5bbf0a31..ee09248fb172 100644 --- a/crates/nu-table/src/types/general.rs +++ b/crates/nu-table/src/types/general.rs @@ -1,7 +1,4 @@ -use nu_color_config::TextStyle; -use nu_engine::column::get_columns; -use nu_protocol::{Config, Record, ShellError, Value}; - +use super::has_index; use crate::{ clean_charset, colorize_space, common::{ @@ -10,8 +7,9 @@ use crate::{ }, NuTable, NuTableCell, StringResult, TableOpts, TableOutput, TableResult, }; - -use super::has_index; +use nu_color_config::TextStyle; +use nu_engine::column::get_columns; +use nu_protocol::{Config, Record, ShellError, Value}; pub struct JustTable; diff --git a/crates/nu-table/src/types/mod.rs b/crates/nu-table/src/types/mod.rs index eeebd70aa3fb..10289c3b814c 100644 --- a/crates/nu-table/src/types/mod.rs +++ b/crates/nu-table/src/types/mod.rs @@ -2,15 +2,14 @@ mod collapse; mod expanded; mod general; -use std::sync::{atomic::AtomicBool, Arc}; - pub use collapse::CollapsedTable; pub use expanded::ExpandedTable; pub use general::JustTable; -use nu_color_config::StyleComputer; -use nu_protocol::{Config, Span, TableIndexMode, TableMode}; use crate::{common::INDEX_COLUMN_NAME, NuTable}; +use nu_color_config::StyleComputer; +use nu_protocol::{Config, Span, TableIndexMode, TableMode}; +use std::sync::{atomic::AtomicBool, Arc}; pub struct TableOutput { pub table: NuTable, diff --git a/crates/nu-table/src/unstructured_table.rs b/crates/nu-table/src/unstructured_table.rs index 9f56cf0f9aa2..58ea117791e1 100644 --- a/crates/nu-table/src/unstructured_table.rs +++ b/crates/nu-table/src/unstructured_table.rs @@ -1,3 +1,4 @@ +use crate::{string_width, string_wrap, TableTheme}; use nu_color_config::StyleComputer; use nu_protocol::{Config, Record, Span, Value}; use tabled::{ @@ -10,8 +11,6 @@ use tabled::{ tables::{PoolTable, TableValue}, }; -use crate::{string_width, string_wrap, TableTheme}; - /// UnstructuredTable has a recursive table representation of nu_protocol::Value. /// /// It doesn't support alignment and a proper width control. diff --git a/crates/nu-table/tests/constrains.rs b/crates/nu-table/tests/constrains.rs index 52dd5d84db52..ea003330114f 100644 --- a/crates/nu-table/tests/constrains.rs +++ b/crates/nu-table/tests/constrains.rs @@ -1,9 +1,8 @@ mod common; +use common::{create_row, test_table, TestCase}; use nu_protocol::TrimStrategy; use nu_table::{NuTable, NuTableConfig, TableTheme as theme}; - -use common::{create_row, test_table, TestCase}; use tabled::grid::records::vec_records::CellInfo; #[test] diff --git a/crates/nu_plugin_custom_values/src/cool_custom_value.rs b/crates/nu_plugin_custom_values/src/cool_custom_value.rs index e2f76cf23dcd..588ad84f1e04 100644 --- a/crates/nu_plugin_custom_values/src/cool_custom_value.rs +++ b/crates/nu_plugin_custom_values/src/cool_custom_value.rs @@ -1,7 +1,6 @@ -use std::cmp::Ordering; - use nu_protocol::{ast, CustomValue, ShellError, Span, Value}; use serde::{Deserialize, Serialize}; +use std::cmp::Ordering; #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] pub struct CoolCustomValue { diff --git a/crates/nu_plugin_custom_values/src/drop_check.rs b/crates/nu_plugin_custom_values/src/drop_check.rs index 7bf005a23390..8a29d546410d 100644 --- a/crates/nu_plugin_custom_values/src/drop_check.rs +++ b/crates/nu_plugin_custom_values/src/drop_check.rs @@ -1,3 +1,4 @@ +use crate::CustomValuePlugin; use nu_plugin::{EngineInterface, EvaluatedCall, SimplePluginCommand}; use nu_protocol::{ record, Category, CustomValue, LabeledError, PluginSignature, ShellError, Span, SyntaxShape, @@ -5,8 +6,6 @@ use nu_protocol::{ }; use serde::{Deserialize, Serialize}; -use crate::CustomValuePlugin; - #[derive(Clone, Debug, Serialize, Deserialize)] pub struct DropCheckValue { pub(crate) msg: String, diff --git a/crates/nu_plugin_custom_values/src/generate.rs b/crates/nu_plugin_custom_values/src/generate.rs index d62a05ecc355..975ceaf04811 100644 --- a/crates/nu_plugin_custom_values/src/generate.rs +++ b/crates/nu_plugin_custom_values/src/generate.rs @@ -1,5 +1,4 @@ use crate::{cool_custom_value::CoolCustomValue, CustomValuePlugin}; - use nu_plugin::{EngineInterface, EvaluatedCall, SimplePluginCommand}; use nu_protocol::{Category, LabeledError, PluginExample, PluginSignature, Span, Value}; diff --git a/crates/nu_plugin_custom_values/src/generate2.rs b/crates/nu_plugin_custom_values/src/generate2.rs index dbc1f88291c4..1a1f89f9a3be 100644 --- a/crates/nu_plugin_custom_values/src/generate2.rs +++ b/crates/nu_plugin_custom_values/src/generate2.rs @@ -1,5 +1,4 @@ use crate::{second_custom_value::SecondCustomValue, CustomValuePlugin}; - use nu_plugin::{EngineInterface, EvaluatedCall, SimplePluginCommand}; use nu_protocol::{ Category, LabeledError, PluginExample, PluginSignature, Span, SyntaxShape, Value, diff --git a/crates/nu_plugin_custom_values/src/update.rs b/crates/nu_plugin_custom_values/src/update.rs index bcdb4d664955..835d7291dfaf 100644 --- a/crates/nu_plugin_custom_values/src/update.rs +++ b/crates/nu_plugin_custom_values/src/update.rs @@ -1,7 +1,6 @@ use crate::{ cool_custom_value::CoolCustomValue, second_custom_value::SecondCustomValue, CustomValuePlugin, }; - use nu_plugin::{EngineInterface, EvaluatedCall, SimplePluginCommand}; use nu_protocol::{ Category, LabeledError, PluginExample, PluginSignature, ShellError, Span, Value, diff --git a/crates/nu_plugin_custom_values/src/update_arg.rs b/crates/nu_plugin_custom_values/src/update_arg.rs index a3f59308007d..5493059dd8b7 100644 --- a/crates/nu_plugin_custom_values/src/update_arg.rs +++ b/crates/nu_plugin_custom_values/src/update_arg.rs @@ -1,5 +1,4 @@ use crate::{update::Update, CustomValuePlugin}; - use nu_plugin::{EngineInterface, EvaluatedCall, SimplePluginCommand}; use nu_protocol::{Category, LabeledError, PluginSignature, SyntaxShape, Value}; diff --git a/crates/nu_plugin_formats/src/from/eml.rs b/crates/nu_plugin_formats/src/from/eml.rs index fe4c51e46324..d0485d16c19b 100644 --- a/crates/nu_plugin_formats/src/from/eml.rs +++ b/crates/nu_plugin_formats/src/from/eml.rs @@ -1,14 +1,13 @@ +use crate::FromCmds; use eml_parser::eml::*; use eml_parser::EmlParser; -use indexmap::map::IndexMap; +use indexmap::IndexMap; use nu_plugin::{EngineInterface, EvaluatedCall, SimplePluginCommand}; -use nu_protocol::LabeledError; use nu_protocol::{ - record, Category, PluginExample, PluginSignature, ShellError, Span, SyntaxShape, Type, Value, + record, Category, LabeledError, PluginExample, PluginSignature, ShellError, Span, SyntaxShape, + Type, Value, }; -use crate::FromCmds; - const DEFAULT_BODY_PREVIEW: usize = 50; pub const CMD_NAME: &str = "from eml"; diff --git a/crates/nu_plugin_formats/src/from/ics.rs b/crates/nu_plugin_formats/src/from/ics.rs index 2447f6eb52cf..890d2d139c05 100644 --- a/crates/nu_plugin_formats/src/from/ics.rs +++ b/crates/nu_plugin_formats/src/from/ics.rs @@ -1,14 +1,12 @@ -use ical::parser::ical::component::*; -use ical::property::Property; -use indexmap::map::IndexMap; +use crate::FromCmds; +use ical::{parser::ical::component::*, property::Property}; +use indexmap::IndexMap; use nu_plugin::{EngineInterface, EvaluatedCall, SimplePluginCommand}; use nu_protocol::{ record, Category, LabeledError, PluginExample, PluginSignature, ShellError, Span, Type, Value, }; use std::io::BufReader; -use crate::FromCmds; - pub const CMD_NAME: &str = "from ics"; pub struct FromIcs; diff --git a/crates/nu_plugin_formats/src/from/ini.rs b/crates/nu_plugin_formats/src/from/ini.rs index ae0ef46a9c7a..e54fd3ab801e 100644 --- a/crates/nu_plugin_formats/src/from/ini.rs +++ b/crates/nu_plugin_formats/src/from/ini.rs @@ -1,10 +1,9 @@ +use crate::FromCmds; use nu_plugin::{EngineInterface, EvaluatedCall, SimplePluginCommand}; use nu_protocol::{ record, Category, LabeledError, PluginExample, PluginSignature, Record, ShellError, Type, Value, }; -use crate::FromCmds; - pub const CMD_NAME: &str = "from ini"; pub struct FromIni; diff --git a/crates/nu_plugin_formats/src/from/vcf.rs b/crates/nu_plugin_formats/src/from/vcf.rs index 47973f8ec04a..4656bc63f613 100644 --- a/crates/nu_plugin_formats/src/from/vcf.rs +++ b/crates/nu_plugin_formats/src/from/vcf.rs @@ -1,13 +1,11 @@ -use ical::parser::vcard::component::*; -use ical::property::Property; -use indexmap::map::IndexMap; +use crate::FromCmds; +use ical::{parser::vcard::component::*, property::Property}; +use indexmap::IndexMap; use nu_plugin::{EngineInterface, EvaluatedCall, SimplePluginCommand}; use nu_protocol::{ record, Category, LabeledError, PluginExample, PluginSignature, ShellError, Span, Type, Value, }; -use crate::FromCmds; - pub const CMD_NAME: &str = "from vcf"; pub struct FromVcf; diff --git a/crates/nu_plugin_gstat/src/gstat.rs b/crates/nu_plugin_gstat/src/gstat.rs index 6248de673d60..849531683dce 100644 --- a/crates/nu_plugin_gstat/src/gstat.rs +++ b/crates/nu_plugin_gstat/src/gstat.rs @@ -1,8 +1,6 @@ use git2::{Branch, BranchType, DescribeOptions, Repository}; use nu_protocol::{record, IntoSpanned, LabeledError, Span, Spanned, Value}; -use std::fmt::Write; -use std::ops::BitAnd; -use std::path::Path; +use std::{fmt::Write, ops::BitAnd, path::Path}; // git status // https://github.com/git/git/blob/9875c515535860450bafd1a177f64f0a478900fa/Documentation/git-status.txt diff --git a/crates/nu_plugin_inc/src/nu/mod.rs b/crates/nu_plugin_inc/src/nu/mod.rs index 4d2de993b2ed..0647d1187cd2 100644 --- a/crates/nu_plugin_inc/src/nu/mod.rs +++ b/crates/nu_plugin_inc/src/nu/mod.rs @@ -1,5 +1,4 @@ -use crate::inc::SemVerAction; -use crate::Inc; +use crate::{inc::SemVerAction, Inc}; use nu_plugin::{EngineInterface, EvaluatedCall, Plugin, PluginCommand, SimplePluginCommand}; use nu_protocol::{ast::CellPath, LabeledError, PluginSignature, SyntaxShape, Value}; diff --git a/crates/nu_plugin_query/src/query.rs b/crates/nu_plugin_query/src/query.rs index b46dccf81ef6..5d76313ac271 100644 --- a/crates/nu_plugin_query/src/query.rs +++ b/crates/nu_plugin_query/src/query.rs @@ -1,7 +1,4 @@ -use crate::query_json::QueryJson; -use crate::query_web::QueryWeb; -use crate::query_xml::QueryXml; - +use crate::{query_json::QueryJson, query_web::QueryWeb, query_xml::QueryXml}; use nu_plugin::{EvaluatedCall, Plugin, PluginCommand, SimplePluginCommand}; use nu_protocol::{Category, LabeledError, PluginSignature, Value}; diff --git a/crates/nu_plugin_query/src/query_json.rs b/crates/nu_plugin_query/src/query_json.rs index bbef6ebfdbb4..5b6aeea03cf9 100644 --- a/crates/nu_plugin_query/src/query_json.rs +++ b/crates/nu_plugin_query/src/query_json.rs @@ -1,11 +1,10 @@ +use crate::Query; use gjson::Value as gjValue; use nu_plugin::{EngineInterface, EvaluatedCall, SimplePluginCommand}; use nu_protocol::{ Category, LabeledError, PluginSignature, Record, Span, Spanned, SyntaxShape, Value, }; -use crate::Query; - pub struct QueryJson; impl SimplePluginCommand for QueryJson { diff --git a/crates/nu_plugin_query/src/query_xml.rs b/crates/nu_plugin_query/src/query_xml.rs index 387e0bdd633b..1c1c527ad410 100644 --- a/crates/nu_plugin_query/src/query_xml.rs +++ b/crates/nu_plugin_query/src/query_xml.rs @@ -1,3 +1,4 @@ +use crate::Query; use nu_plugin::{EngineInterface, EvaluatedCall, SimplePluginCommand}; use nu_protocol::{ record, Category, LabeledError, PluginSignature, Record, Span, Spanned, SyntaxShape, Value, @@ -5,8 +6,6 @@ use nu_protocol::{ use sxd_document::parser; use sxd_xpath::{Context, Factory}; -use crate::Query; - pub struct QueryXml; impl SimplePluginCommand for QueryXml { diff --git a/src/command.rs b/src/command.rs index f3b4c7a5c083..f6f06d04da1a 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1,12 +1,9 @@ -use nu_engine::{get_full_help, CallExt}; -use nu_parser::parse; -use nu_parser::{escape_for_script_arg, escape_quote_string}; -use nu_protocol::report_error; +use nu_engine::{command_prelude::*, get_full_help}; +use nu_parser::{escape_for_script_arg, escape_quote_string, parse}; use nu_protocol::{ - ast::{Call, Expr, Expression}, - engine::{Command, EngineState, Stack, StateWorkingSet}, - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Spanned, SyntaxShape, - Value, + ast::{Expr, Expression}, + engine::StateWorkingSet, + report_error, }; use nu_utils::stdout_write_all_and_flush; diff --git a/src/config_files.rs b/src/config_files.rs index d2ccf87d5071..3091bda199af 100644 --- a/src/config_files.rs +++ b/src/config_files.rs @@ -3,15 +3,18 @@ use log::info; use nu_cli::read_plugin_file; use nu_cli::{eval_config_contents, eval_source}; use nu_path::canonicalize_with; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::{report_error, Config}; -use nu_protocol::{ParseError, PipelineData, Spanned}; +use nu_protocol::{ + engine::{EngineState, Stack, StateWorkingSet}, + report_error, Config, ParseError, PipelineData, Spanned, +}; use nu_utils::{get_default_config, get_default_env}; -use std::fs::File; -use std::io::Write; -use std::panic::{catch_unwind, AssertUnwindSafe}; -use std::path::Path; -use std::sync::Arc; +use std::{ + fs::File, + io::Write, + panic::{catch_unwind, AssertUnwindSafe}, + path::Path, + sync::Arc, +}; pub(crate) const NUSHELL_FOLDER: &str = "nushell"; const CONFIG_FILE: &str = "config.nu"; diff --git a/src/run.rs b/src/run.rs index 1329cf64d091..4f0edcde05c8 100644 --- a/src/run.rs +++ b/src/run.rs @@ -7,8 +7,7 @@ use crate::{ #[cfg(feature = "plugin")] use nu_cli::read_plugin_file; use nu_cli::{evaluate_commands, evaluate_file, evaluate_repl}; -use nu_protocol::eval_const::create_nu_constant; -use nu_protocol::{PipelineData, Span, NU_VARIABLE_ID}; +use nu_protocol::{eval_const::create_nu_constant, PipelineData, Span, NU_VARIABLE_ID}; use nu_utils::utils::perf; pub(crate) fn run_commands( diff --git a/src/signals.rs b/src/signals.rs index 740c02074547..9247ccb09599 100644 --- a/src/signals.rs +++ b/src/signals.rs @@ -1,10 +1,9 @@ +use nu_protocol::engine::EngineState; use std::sync::{ atomic::{AtomicBool, Ordering}, Arc, }; -use nu_protocol::engine::EngineState; - pub(crate) fn ctrlc_protection(engine_state: &mut EngineState, ctrlc: &Arc) { let handler_ctrlc = ctrlc.clone(); let engine_state_ctrlc = ctrlc.clone(); diff --git a/src/test_bins.rs b/src/test_bins.rs index 1605b5601c3b..26c9dd6a0a74 100644 --- a/src/test_bins.rs +++ b/src/test_bins.rs @@ -1,9 +1,12 @@ use nu_cmd_base::hook::{eval_env_change_hook, eval_hook}; use nu_engine::eval_block; use nu_parser::parse; -use nu_protocol::debugger::WithoutDebug; -use nu_protocol::engine::{EngineState, Stack, StateWorkingSet}; -use nu_protocol::{cli_error::CliError, PipelineData, Value}; +use nu_protocol::{ + cli_error::CliError, + debugger::WithoutDebug, + engine::{EngineState, Stack, StateWorkingSet}, + PipelineData, Value, +}; use nu_std::load_standard_library; use std::io::{self, BufRead, Read, Write};