Rust 1.85, edition=2024 (#15741)

This commit is contained in:
Jack Wright 2025-05-13 07:49:30 -07:00 committed by GitHub
parent 1a0986903f
commit c2ac8f730e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
793 changed files with 4276 additions and 3687 deletions

16
Cargo.lock generated
View File

@ -730,9 +730,9 @@ dependencies = [
[[package]] [[package]]
name = "blake3" name = "blake3"
version = "1.5.5" version = "1.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8ee0c1824c4dea5b5f81736aff91bae041d2c07ee1192bec91054e10e3e601e" checksum = "3888aaa89e4b2a40fca9848e400f6a658a5a3978de7be858e209cafa8be9a4a0"
dependencies = [ dependencies = [
"arrayref", "arrayref",
"arrayvec 0.7.6", "arrayvec 0.7.6",
@ -811,9 +811,9 @@ checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.21.0" version = "1.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" checksum = "9134a6ef01ce4b366b50689c94f82c14bc72bc5d0386829828a2e2752ef7958c"
dependencies = [ dependencies = [
"bytemuck_derive", "bytemuck_derive",
] ]
@ -1649,9 +1649,9 @@ checksum = "b2972feb8dffe7bc8c5463b1dacda1b0dfbed3710e50f977d965429692d74cd8"
[[package]] [[package]]
name = "either" name = "either"
version = "1.13.0" version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -1894,9 +1894,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]] [[package]]
name = "foldhash" name = "foldhash"
version = "0.1.3" version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]] [[package]]
name = "foreign-types" name = "foreign-types"

View File

@ -4,13 +4,13 @@ build = "scripts/build.rs"
default-run = "nu" default-run = "nu"
description = "A new type of shell" description = "A new type of shell"
documentation = "https://www.nushell.sh/book/" documentation = "https://www.nushell.sh/book/"
edition = "2021" edition = "2024"
exclude = ["images"] exclude = ["images"]
homepage = "https://www.nushell.sh" homepage = "https://www.nushell.sh"
license = "MIT" license = "MIT"
name = "nu" name = "nu"
repository = "https://github.com/nushell/nushell" repository = "https://github.com/nushell/nushell"
rust-version = "1.84.1" rust-version = "1.85.1"
version = "0.104.1" version = "0.104.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,8 +2,8 @@ use nu_cli::{eval_source, evaluate_commands};
use nu_plugin_core::{Encoder, EncodingType}; use nu_plugin_core::{Encoder, EncodingType};
use nu_plugin_protocol::{PluginCallResponse, PluginOutput}; use nu_plugin_protocol::{PluginCallResponse, PluginOutput};
use nu_protocol::{ use nu_protocol::{
engine::{EngineState, Stack},
PipelineData, Signals, Span, Spanned, Value, PipelineData, Signals, Span, Spanned, Value,
engine::{EngineState, Stack},
}; };
use nu_std::load_standard_library; use nu_std::load_standard_library;
use nu_utils::{get_default_config, get_default_env}; use nu_utils::{get_default_config, get_default_env};
@ -11,9 +11,9 @@ use std::{
fmt::Write, fmt::Write,
hint::black_box, hint::black_box,
rc::Rc, rc::Rc,
sync::{atomic::AtomicBool, Arc}, sync::{Arc, atomic::AtomicBool},
}; };
use tango_bench::{benchmark_fn, tango_benchmarks, tango_main, IntoBenchmarks}; use tango_bench::{IntoBenchmarks, benchmark_fn, tango_benchmarks, tango_main};
fn load_bench_commands() -> EngineState { fn load_bench_commands() -> EngineState {
nu_command::add_shell_command_context(nu_cmd_lang::create_default_context()) nu_command::add_shell_command_context(nu_cmd_lang::create_default_context())
@ -68,14 +68,14 @@ fn encoding_test_data(row_cnt: usize, col_cnt: usize) -> Value {
} }
fn bench_command( fn bench_command(
name: &str, name: impl Into<String>,
command: &str, command: impl Into<String> + Clone,
stack: Stack, stack: Stack,
engine: EngineState, engine: EngineState,
) -> impl IntoBenchmarks { ) -> impl IntoBenchmarks {
let commands = Spanned { let commands = Spanned {
span: Span::unknown(), span: Span::unknown(),
item: command.to_string(), item: command.into(),
}; };
[benchmark_fn(name, move |b| { [benchmark_fn(name, move |b| {
let commands = commands.clone(); let commands = commands.clone();
@ -175,8 +175,8 @@ fn create_example_table_nrows(n: usize) -> String {
fn bench_record_create(n: usize) -> impl IntoBenchmarks { fn bench_record_create(n: usize) -> impl IntoBenchmarks {
bench_command( bench_command(
&format!("record_create_{n}"), format!("record_create_{n}"),
&create_flat_record_string(n), create_flat_record_string(n),
Stack::new(), Stack::new(),
setup_engine(), setup_engine(),
) )
@ -186,7 +186,7 @@ fn bench_record_flat_access(n: usize) -> impl IntoBenchmarks {
let setup_command = create_flat_record_string(n); let setup_command = create_flat_record_string(n);
let (stack, engine) = setup_stack_and_engine_from_command(&setup_command); let (stack, engine) = setup_stack_and_engine_from_command(&setup_command);
bench_command( bench_command(
&format!("record_flat_access_{n}"), format!("record_flat_access_{n}"),
"$record.col_0 | ignore", "$record.col_0 | ignore",
stack, stack,
engine, engine,
@ -198,8 +198,8 @@ fn bench_record_nested_access(n: usize) -> impl IntoBenchmarks {
let (stack, engine) = setup_stack_and_engine_from_command(&setup_command); let (stack, engine) = setup_stack_and_engine_from_command(&setup_command);
let nested_access = ".col".repeat(n); let nested_access = ".col".repeat(n);
bench_command( bench_command(
&format!("record_nested_access_{n}"), format!("record_nested_access_{n}"),
&format!("$record{} | ignore", nested_access), format!("$record{} | ignore", nested_access),
stack, stack,
engine, engine,
) )
@ -213,13 +213,13 @@ fn bench_record_insert(n: usize, m: usize) -> impl IntoBenchmarks {
write!(insert, " | insert col_{i} {i}").unwrap(); write!(insert, " | insert col_{i} {i}").unwrap();
} }
insert.push_str(" | ignore"); insert.push_str(" | ignore");
bench_command(&format!("record_insert_{n}_{m}"), &insert, stack, engine) bench_command(format!("record_insert_{n}_{m}"), insert, stack, engine)
} }
fn bench_table_create(n: usize) -> impl IntoBenchmarks { fn bench_table_create(n: usize) -> impl IntoBenchmarks {
bench_command( bench_command(
&format!("table_create_{n}"), format!("table_create_{n}"),
&create_example_table_nrows(n), create_example_table_nrows(n),
Stack::new(), Stack::new(),
setup_engine(), setup_engine(),
) )
@ -229,7 +229,7 @@ fn bench_table_get(n: usize) -> impl IntoBenchmarks {
let setup_command = create_example_table_nrows(n); let setup_command = create_example_table_nrows(n);
let (stack, engine) = setup_stack_and_engine_from_command(&setup_command); let (stack, engine) = setup_stack_and_engine_from_command(&setup_command);
bench_command( bench_command(
&format!("table_get_{n}"), format!("table_get_{n}"),
"$table | get bar | math sum | ignore", "$table | get bar | math sum | ignore",
stack, stack,
engine, engine,
@ -240,7 +240,7 @@ fn bench_table_select(n: usize) -> impl IntoBenchmarks {
let setup_command = create_example_table_nrows(n); let setup_command = create_example_table_nrows(n);
let (stack, engine) = setup_stack_and_engine_from_command(&setup_command); let (stack, engine) = setup_stack_and_engine_from_command(&setup_command);
bench_command( bench_command(
&format!("table_select_{n}"), format!("table_select_{n}"),
"$table | select foo baz | ignore", "$table | select foo baz | ignore",
stack, stack,
engine, engine,
@ -255,7 +255,7 @@ fn bench_table_insert_row(n: usize, m: usize) -> impl IntoBenchmarks {
write!(insert, " | insert {i} {{ foo: 0, bar: 1, baz: {i} }}").unwrap(); write!(insert, " | insert {i} {{ foo: 0, bar: 1, baz: {i} }}").unwrap();
} }
insert.push_str(" | ignore"); insert.push_str(" | ignore");
bench_command(&format!("table_insert_row_{n}_{m}"), &insert, stack, engine) bench_command(format!("table_insert_row_{n}_{m}"), insert, stack, engine)
} }
fn bench_table_insert_col(n: usize, m: usize) -> impl IntoBenchmarks { fn bench_table_insert_col(n: usize, m: usize) -> impl IntoBenchmarks {
@ -266,15 +266,15 @@ fn bench_table_insert_col(n: usize, m: usize) -> impl IntoBenchmarks {
write!(insert, " | insert col_{i} {i}").unwrap(); write!(insert, " | insert col_{i} {i}").unwrap();
} }
insert.push_str(" | ignore"); insert.push_str(" | ignore");
bench_command(&format!("table_insert_col_{n}_{m}"), &insert, stack, engine) bench_command(format!("table_insert_col_{n}_{m}"), insert, stack, engine)
} }
fn bench_eval_interleave(n: usize) -> impl IntoBenchmarks { fn bench_eval_interleave(n: usize) -> impl IntoBenchmarks {
let engine = setup_engine(); let engine = setup_engine();
let stack = Stack::new(); let stack = Stack::new();
bench_command( bench_command(
&format!("eval_interleave_{n}"), format!("eval_interleave_{n}"),
&format!("seq 1 {n} | wrap a | interleave {{ seq 1 {n} | wrap b }} | ignore"), format!("seq 1 {n} | wrap a | interleave {{ seq 1 {n} | wrap b }} | ignore"),
stack, stack,
engine, engine,
) )
@ -285,8 +285,8 @@ fn bench_eval_interleave_with_interrupt(n: usize) -> impl IntoBenchmarks {
engine.set_signals(Signals::new(Arc::new(AtomicBool::new(false)))); engine.set_signals(Signals::new(Arc::new(AtomicBool::new(false))));
let stack = Stack::new(); let stack = Stack::new();
bench_command( bench_command(
&format!("eval_interleave_with_interrupt_{n}"), format!("eval_interleave_with_interrupt_{n}"),
&format!("seq 1 {n} | wrap a | interleave {{ seq 1 {n} | wrap b }} | ignore"), format!("seq 1 {n} | wrap a | interleave {{ seq 1 {n} | wrap b }} | ignore"),
stack, stack,
engine, engine,
) )
@ -296,8 +296,8 @@ fn bench_eval_for(n: usize) -> impl IntoBenchmarks {
let engine = setup_engine(); let engine = setup_engine();
let stack = Stack::new(); let stack = Stack::new();
bench_command( bench_command(
&format!("eval_for_{n}"), format!("eval_for_{n}"),
&format!("(for $x in (1..{n}) {{ 1 }}) | ignore"), format!("(for $x in (1..{n}) {{ 1 }}) | ignore"),
stack, stack,
engine, engine,
) )
@ -307,8 +307,8 @@ fn bench_eval_each(n: usize) -> impl IntoBenchmarks {
let engine = setup_engine(); let engine = setup_engine();
let stack = Stack::new(); let stack = Stack::new();
bench_command( bench_command(
&format!("eval_each_{n}"), format!("eval_each_{n}"),
&format!("(1..{n}) | each {{|_| 1 }} | ignore"), format!("(1..{n}) | each {{|_| 1 }} | ignore"),
stack, stack,
engine, engine,
) )
@ -318,8 +318,8 @@ fn bench_eval_par_each(n: usize) -> impl IntoBenchmarks {
let engine = setup_engine(); let engine = setup_engine();
let stack = Stack::new(); let stack = Stack::new();
bench_command( bench_command(
&format!("eval_par_each_{n}"), format!("eval_par_each_{n}"),
&format!("(1..{}) | par-each -t 2 {{|_| 1 }} | ignore", n), format!("(1..{}) | par-each -t 2 {{|_| 1 }} | ignore", n),
stack, stack,
engine, engine,
) )

View File

@ -2,7 +2,7 @@
authors = ["The Nushell Project Developers"] authors = ["The Nushell Project Developers"]
description = "CLI-related functionality for Nushell" description = "CLI-related functionality for Nushell"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cli" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cli"
edition = "2021" edition = "2024"
license = "MIT" license = "MIT"
name = "nu-cli" name = "nu-cli"
version = "0.104.1" version = "0.104.1"

View File

@ -1,5 +1,5 @@
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
use nu_protocol::{shell_error::io::IoError, HistoryFileFormat}; use nu_protocol::{HistoryFileFormat, shell_error::io::IoError};
use reedline::{ use reedline::{
FileBackedHistory, History as ReedlineHistory, HistoryItem, SearchDirection, SearchQuery, FileBackedHistory, History as ReedlineHistory, HistoryItem, SearchDirection, SearchQuery,
SqliteBackedHistory, SqliteBackedHistory,

View File

@ -2,8 +2,8 @@ use std::path::{Path, PathBuf};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
use nu_protocol::{ use nu_protocol::{
shell_error::{self, io::IoError},
HistoryFileFormat, HistoryFileFormat,
shell_error::{self, io::IoError},
}; };
use reedline::{ use reedline::{
@ -48,8 +48,7 @@ Note that history item IDs are ignored when importing from file."#
vec![ vec![
Example { Example {
example: "history import", example: "history import",
description: description: "Append all items from history in the other format to the current history",
"Append all items from history in the other format to the current history",
result: None, result: None,
}, },
Example { Example {
@ -198,7 +197,7 @@ fn item_from_record(mut rec: Record, span: Span) -> Result<HistoryItem, ShellErr
return Err(ShellError::TypeMismatch { return Err(ShellError::TypeMismatch {
err_message: format!("missing column: {}", fields::COMMAND_LINE), err_message: format!("missing column: {}", fields::COMMAND_LINE),
span, span,
}) });
} }
}; };
@ -283,7 +282,7 @@ fn backup(path: &Path, span: Span) -> Result<Option<PathBuf>, ShellError> {
PathBuf::from(path), PathBuf::from(path),
"history path exists but is not a file", "history path exists but is not a file",
) )
.into()) .into());
} }
Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(None), Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(None),
Err(e) => { Err(e) => {
@ -292,7 +291,7 @@ fn backup(path: &Path, span: Span) -> Result<Option<PathBuf>, ShellError> {
"Could not get metadata", "Could not get metadata",
nu_protocol::location!(), nu_protocol::location!(),
) )
.into()) .into());
} }
} }
let bak_path = find_backup_path(path, span)?; let bak_path = find_backup_path(path, span)?;

View File

@ -1,9 +1,9 @@
use crossterm::{ use crossterm::{
event::Event, event::KeyCode, event::KeyEvent, execute, terminal, QueueableCommand, QueueableCommand, event::Event, event::KeyCode, event::KeyEvent, execute, terminal,
}; };
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
use nu_protocol::shell_error::io::IoError; use nu_protocol::shell_error::io::IoError;
use std::io::{stdout, Write}; use std::io::{Write, stdout};
#[derive(Clone)] #[derive(Clone)]
pub struct KeybindingsListen; pub struct KeybindingsListen;

View File

@ -1,11 +1,11 @@
use super::{completion_options::NuMatcher, SemanticSuggestion}; use super::{SemanticSuggestion, completion_options::NuMatcher};
use crate::{ use crate::{
completions::{Completer, CompletionOptions},
SuggestionKind, SuggestionKind,
completions::{Completer, CompletionOptions},
}; };
use nu_protocol::{ use nu_protocol::{
engine::{Stack, StateWorkingSet},
Span, Span,
engine::{Stack, StateWorkingSet},
}; };
use reedline::Suggestion; use reedline::Suggestion;

View File

@ -1,7 +1,7 @@
use crate::completions::CompletionOptions; use crate::completions::CompletionOptions;
use nu_protocol::{ use nu_protocol::{
engine::{Stack, StateWorkingSet},
DeclId, Span, DeclId, Span,
engine::{Stack, StateWorkingSet},
}; };
use reedline::Suggestion; use reedline::Suggestion;

View File

@ -3,10 +3,10 @@ use std::borrow::Cow;
use crate::completions::{Completer, CompletionOptions, SemanticSuggestion, SuggestionKind}; use crate::completions::{Completer, CompletionOptions, SemanticSuggestion, SuggestionKind};
use nu_engine::{column::get_columns, eval_variable}; use nu_engine::{column::get_columns, eval_variable};
use nu_protocol::{ use nu_protocol::{
ShellError, Span, Value,
ast::{Expr, Expression, FullCellPath, PathMember}, ast::{Expr, Expression, FullCellPath, PathMember},
engine::{Stack, StateWorkingSet}, engine::{Stack, StateWorkingSet},
eval_const::eval_constant, eval_const::eval_constant,
ShellError, Span, Value,
}; };
use reedline::Suggestion; use reedline::Suggestion;

View File

@ -1,16 +1,16 @@
use std::collections::HashMap; use std::collections::HashMap;
use crate::{ use crate::{
completions::{Completer, CompletionOptions},
SuggestionKind, SuggestionKind,
completions::{Completer, CompletionOptions},
}; };
use nu_protocol::{ use nu_protocol::{
engine::{CommandType, Stack, StateWorkingSet},
Span, Span,
engine::{CommandType, Stack, StateWorkingSet},
}; };
use reedline::Suggestion; use reedline::Suggestion;
use super::{completion_options::NuMatcher, SemanticSuggestion}; use super::{SemanticSuggestion, completion_options::NuMatcher};
pub struct CommandCompletion { pub struct CommandCompletion {
/// Whether to include internal commands /// Whether to include internal commands

View File

@ -1,17 +1,17 @@
use crate::completions::{ use crate::completions::{
base::{SemanticSuggestion, SuggestionKind},
AttributableCompletion, AttributeCompletion, CellPathCompletion, CommandCompletion, Completer, AttributableCompletion, AttributeCompletion, CellPathCompletion, CommandCompletion, Completer,
CompletionOptions, CustomCompletion, DirectoryCompletion, DotNuCompletion, CompletionOptions, CustomCompletion, DirectoryCompletion, DotNuCompletion,
ExportableCompletion, FileCompletion, FlagCompletion, OperatorCompletion, VariableCompletion, ExportableCompletion, FileCompletion, FlagCompletion, OperatorCompletion, VariableCompletion,
base::{SemanticSuggestion, SuggestionKind},
}; };
use nu_color_config::{color_record_to_nustyle, lookup_ansi_color_style}; use nu_color_config::{color_record_to_nustyle, lookup_ansi_color_style};
use nu_engine::eval_block; use nu_engine::eval_block;
use nu_parser::{flatten_expression, parse, parse_module_file_or_dir}; use nu_parser::{flatten_expression, parse, parse_module_file_or_dir};
use nu_protocol::{ use nu_protocol::{
PipelineData, Span, Type, Value,
ast::{Argument, Block, Expr, Expression, FindMapResult, ListItem, Traverse}, ast::{Argument, Block, Expr, Expression, FindMapResult, ListItem, Traverse},
debugger::WithoutDebug, debugger::WithoutDebug,
engine::{Closure, EngineState, Stack, StateWorkingSet}, engine::{Closure, EngineState, Stack, StateWorkingSet},
PipelineData, Span, Type, Value,
}; };
use reedline::{Completer as ReedlineCompleter, Suggestion}; use reedline::{Completer as ReedlineCompleter, Suggestion};
use std::sync::Arc; use std::sync::Arc;

View File

@ -1,16 +1,16 @@
use super::{completion_options::NuMatcher, MatchAlgorithm}; use super::{MatchAlgorithm, completion_options::NuMatcher};
use crate::completions::CompletionOptions; use crate::completions::CompletionOptions;
use nu_ansi_term::Style; use nu_ansi_term::Style;
use nu_engine::env_to_string; use nu_engine::env_to_string;
use nu_path::dots::expand_ndots; use nu_path::dots::expand_ndots;
use nu_path::{expand_to_real_path, home_dir}; use nu_path::{expand_to_real_path, home_dir};
use nu_protocol::{ use nu_protocol::{
engine::{EngineState, Stack, StateWorkingSet},
Span, Span,
engine::{EngineState, Stack, StateWorkingSet},
}; };
use nu_utils::get_ls_colors;
use nu_utils::IgnoreCaseExt; use nu_utils::IgnoreCaseExt;
use std::path::{is_separator, Component, Path, PathBuf, MAIN_SEPARATOR as SEP}; use nu_utils::get_ls_colors;
use std::path::{Component, MAIN_SEPARATOR as SEP, Path, PathBuf, is_separator};
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct PathBuiltFromString { pub struct PathBuiltFromString {

View File

@ -2,8 +2,8 @@ use nu_parser::trim_quotes_str;
use nu_protocol::{CompletionAlgorithm, CompletionSort}; use nu_protocol::{CompletionAlgorithm, CompletionSort};
use nu_utils::IgnoreCaseExt; use nu_utils::IgnoreCaseExt;
use nucleo_matcher::{ use nucleo_matcher::{
pattern::{Atom, AtomKind, CaseMatching, Normalization},
Config, Matcher, Utf32Str, Config, Matcher, Utf32Str,
pattern::{Atom, AtomKind, CaseMatching, Normalization},
}; };
use std::{borrow::Cow, fmt::Display}; use std::{borrow::Cow, fmt::Display};

View File

@ -1,13 +1,13 @@
use crate::completions::{ use crate::completions::{
completer::map_value_completions, Completer, CompletionOptions, MatchAlgorithm, Completer, CompletionOptions, MatchAlgorithm, SemanticSuggestion,
SemanticSuggestion, completer::map_value_completions,
}; };
use nu_engine::eval_call; use nu_engine::eval_call;
use nu_protocol::{ use nu_protocol::{
DeclId, PipelineData, Span, Type, Value,
ast::{Argument, Call, Expr, Expression}, ast::{Argument, Call, Expr, Expression},
debugger::WithoutDebug, debugger::WithoutDebug,
engine::{EngineState, Stack, StateWorkingSet}, engine::{EngineState, Stack, StateWorkingSet},
DeclId, PipelineData, Span, Type, Value,
}; };
use std::collections::HashMap; use std::collections::HashMap;
@ -106,7 +106,9 @@ impl<T: Completer> Completer for CustomCompletion<T> {
let positional = let positional =
options.get("positional").and_then(|val| val.as_bool().ok()); options.get("positional").and_then(|val| val.as_bool().ok());
if positional.is_some() { if positional.is_some() {
log::warn!("Use of the positional option is deprecated. Use the substring match algorithm instead."); log::warn!(
"Use of the positional option is deprecated. Use the substring match algorithm instead."
);
} }
if let Some(algorithm) = options if let Some(algorithm) = options
.get("completion_algorithm") .get("completion_algorithm")

View File

@ -1,15 +1,15 @@
use crate::completions::{ use crate::completions::{
completion_common::{adjust_if_intermediate, complete_item, AdjustView},
Completer, CompletionOptions, Completer, CompletionOptions,
completion_common::{AdjustView, adjust_if_intermediate, complete_item},
}; };
use nu_protocol::{ use nu_protocol::{
engine::{EngineState, Stack, StateWorkingSet},
Span, Span,
engine::{EngineState, Stack, StateWorkingSet},
}; };
use reedline::Suggestion; use reedline::Suggestion;
use std::path::Path; use std::path::Path;
use super::{completion_common::FileSuggestion, SemanticSuggestion, SuggestionKind}; use super::{SemanticSuggestion, SuggestionKind, completion_common::FileSuggestion};
pub struct DirectoryCompletion; pub struct DirectoryCompletion;

View File

@ -1,17 +1,18 @@
use crate::completions::{ use crate::completions::{
completion_common::{surround_remove, FileSuggestion}, Completer, CompletionOptions, SemanticSuggestion, SuggestionKind,
completion_common::{FileSuggestion, surround_remove},
completion_options::NuMatcher, completion_options::NuMatcher,
file_path_completion, Completer, CompletionOptions, SemanticSuggestion, SuggestionKind, file_path_completion,
}; };
use nu_path::expand_tilde; use nu_path::expand_tilde;
use nu_protocol::{ use nu_protocol::{
engine::{Stack, StateWorkingSet, VirtualPath},
Span, Span,
engine::{Stack, StateWorkingSet, VirtualPath},
}; };
use reedline::Suggestion; use reedline::Suggestion;
use std::{ use std::{
collections::HashSet, collections::HashSet,
path::{is_separator, PathBuf, MAIN_SEPARATOR_STR}, path::{MAIN_SEPARATOR_STR, PathBuf, is_separator},
}; };
pub struct DotNuCompletion { pub struct DotNuCompletion {

View File

@ -1,10 +1,10 @@
use crate::completions::{ use crate::completions::{
completion_common::surround_remove, completion_options::NuMatcher, Completer, Completer, CompletionOptions, SemanticSuggestion, SuggestionKind,
CompletionOptions, SemanticSuggestion, SuggestionKind, completion_common::surround_remove, completion_options::NuMatcher,
}; };
use nu_protocol::{ use nu_protocol::{
engine::{Stack, StateWorkingSet},
ModuleId, Span, ModuleId, Span,
engine::{Stack, StateWorkingSet},
}; };
use reedline::Suggestion; use reedline::Suggestion;

View File

@ -1,15 +1,15 @@
use crate::completions::{ use crate::completions::{
completion_common::{adjust_if_intermediate, complete_item, AdjustView},
Completer, CompletionOptions, Completer, CompletionOptions,
completion_common::{AdjustView, adjust_if_intermediate, complete_item},
}; };
use nu_protocol::{ use nu_protocol::{
engine::{EngineState, Stack, StateWorkingSet},
Span, Span,
engine::{EngineState, Stack, StateWorkingSet},
}; };
use reedline::Suggestion; use reedline::Suggestion;
use std::path::Path; use std::path::Path;
use super::{completion_common::FileSuggestion, SemanticSuggestion, SuggestionKind}; use super::{SemanticSuggestion, SuggestionKind, completion_common::FileSuggestion};
pub struct FileCompletion; pub struct FileCompletion;

View File

@ -1,9 +1,9 @@
use crate::completions::{ use crate::completions::{
completion_options::NuMatcher, Completer, CompletionOptions, SemanticSuggestion, SuggestionKind, Completer, CompletionOptions, SemanticSuggestion, SuggestionKind, completion_options::NuMatcher,
}; };
use nu_protocol::{ use nu_protocol::{
engine::{Stack, StateWorkingSet},
DeclId, Span, DeclId, Span,
engine::{Stack, StateWorkingSet},
}; };
use reedline::Suggestion; use reedline::Suggestion;

View File

@ -24,7 +24,7 @@ pub use custom_completions::CustomCompletion;
pub use directory_completions::DirectoryCompletion; pub use directory_completions::DirectoryCompletion;
pub use dotnu_completions::DotNuCompletion; pub use dotnu_completions::DotNuCompletion;
pub use exportable_completions::ExportableCompletion; pub use exportable_completions::ExportableCompletion;
pub use file_completions::{file_path_completion, FileCompletion}; pub use file_completions::{FileCompletion, file_path_completion};
pub use flag_completions::FlagCompletion; pub use flag_completions::FlagCompletion;
pub use operator_completions::OperatorCompletion; pub use operator_completions::OperatorCompletion;
pub use variable_completions::VariableCompletion; pub use variable_completions::VariableCompletion;

View File

@ -1,10 +1,10 @@
use crate::completions::{ use crate::completions::{
completion_options::NuMatcher, Completer, CompletionOptions, SemanticSuggestion, SuggestionKind, Completer, CompletionOptions, SemanticSuggestion, SuggestionKind, completion_options::NuMatcher,
}; };
use nu_protocol::{ use nu_protocol::{
ENV_VARIABLE_ID, Span, Type, Value,
ast::{self, Comparison, Expr, Expression}, ast::{self, Comparison, Expr, Expression},
engine::{Stack, StateWorkingSet}, engine::{Stack, StateWorkingSet},
Span, Type, Value, ENV_VARIABLE_ID,
}; };
use reedline::Suggestion; use reedline::Suggestion;
use strum::{EnumMessage, IntoEnumIterator}; use strum::{EnumMessage, IntoEnumIterator};

View File

@ -1,7 +1,7 @@
use crate::completions::{Completer, CompletionOptions, SemanticSuggestion, SuggestionKind}; use crate::completions::{Completer, CompletionOptions, SemanticSuggestion, SuggestionKind};
use nu_protocol::{ use nu_protocol::{
engine::{Stack, StateWorkingSet},
Span, VarId, Span, VarId,
engine::{Stack, StateWorkingSet},
}; };
use reedline::Suggestion; use reedline::Suggestion;

View File

@ -2,10 +2,11 @@ use crate::util::eval_source;
#[cfg(feature = "plugin")] #[cfg(feature = "plugin")]
use nu_path::canonicalize_with; use nu_path::canonicalize_with;
#[cfg(feature = "plugin")] #[cfg(feature = "plugin")]
use nu_protocol::{engine::StateWorkingSet, ParseError, PluginRegistryFile, Spanned}; use nu_protocol::{ParseError, PluginRegistryFile, Spanned, engine::StateWorkingSet};
use nu_protocol::{ use nu_protocol::{
PipelineData,
engine::{EngineState, Stack}, engine::{EngineState, Stack},
report_shell_error, PipelineData, report_shell_error,
}; };
#[cfg(feature = "plugin")] #[cfg(feature = "plugin")]
use nu_utils::perf; use nu_utils::perf;
@ -18,7 +19,7 @@ const OLD_PLUGIN_FILE: &str = "plugin.nu";
#[cfg(feature = "plugin")] #[cfg(feature = "plugin")]
pub fn read_plugin_file(engine_state: &mut EngineState, plugin_file: Option<Spanned<String>>) { pub fn read_plugin_file(engine_state: &mut EngineState, plugin_file: Option<Spanned<String>>) {
use nu_protocol::{shell_error::io::IoError, ShellError}; use nu_protocol::{ShellError, shell_error::io::IoError};
use std::path::Path; use std::path::Path;
let span = plugin_file.as_ref().map(|s| s.span); let span = plugin_file.as_ref().map(|s| s.span);
@ -230,8 +231,8 @@ pub fn eval_config_contents(
#[cfg(feature = "plugin")] #[cfg(feature = "plugin")]
pub fn migrate_old_plugin_file(engine_state: &EngineState) -> bool { pub fn migrate_old_plugin_file(engine_state: &EngineState) -> bool {
use nu_protocol::{ use nu_protocol::{
shell_error::io::IoError, PluginExample, PluginIdentity, PluginRegistryItem, PluginExample, PluginIdentity, PluginRegistryItem, PluginRegistryItemData, PluginSignature,
PluginRegistryItemData, PluginSignature, ShellError, ShellError, shell_error::io::IoError,
}; };
use std::collections::BTreeMap; use std::collections::BTreeMap;

View File

@ -2,10 +2,11 @@ use log::info;
use nu_engine::eval_block; use nu_engine::eval_block;
use nu_parser::parse; use nu_parser::parse;
use nu_protocol::{ use nu_protocol::{
PipelineData, ShellError, Spanned, Value,
cli_error::report_compile_error, cli_error::report_compile_error,
debugger::WithoutDebug, debugger::WithoutDebug,
engine::{EngineState, Stack, StateWorkingSet}, engine::{EngineState, Stack, StateWorkingSet},
report_parse_error, report_parse_warning, PipelineData, ShellError, Spanned, Value, report_parse_error, report_parse_warning,
}; };
use std::sync::Arc; use std::sync::Arc;

View File

@ -4,12 +4,12 @@ use nu_engine::eval_block;
use nu_parser::parse; use nu_parser::parse;
use nu_path::canonicalize_with; use nu_path::canonicalize_with;
use nu_protocol::{ use nu_protocol::{
PipelineData, ShellError, Span, Value,
cli_error::report_compile_error, cli_error::report_compile_error,
debugger::WithoutDebug, debugger::WithoutDebug,
engine::{EngineState, Stack, StateWorkingSet}, engine::{EngineState, Stack, StateWorkingSet},
report_parse_error, report_parse_warning, report_parse_error, report_parse_warning,
shell_error::io::*, shell_error::io::*,
PipelineData, ShellError, Span, Value,
}; };
use std::{path::PathBuf, sync::Arc}; use std::{path::PathBuf, sync::Arc};

View File

@ -18,7 +18,7 @@ mod validation;
pub use commands::add_cli_context; pub use commands::add_cli_context;
pub use completions::{FileCompletion, NuCompleter, SemanticSuggestion, SuggestionKind}; pub use completions::{FileCompletion, NuCompleter, SemanticSuggestion, SuggestionKind};
pub use config_files::eval_config_contents; pub use config_files::eval_config_contents;
pub use eval_cmds::{evaluate_commands, EvaluateCommandsOpts}; pub use eval_cmds::{EvaluateCommandsOpts, evaluate_commands};
pub use eval_file::evaluate_file; pub use eval_file::evaluate_file;
pub use menus::NuHelpCompleter; pub use menus::NuHelpCompleter;
pub use nu_highlight::NuHighlight; pub use nu_highlight::NuHighlight;

View File

@ -1,5 +1,5 @@
use nu_engine::documentation::{get_flags_section, HelpStyle}; use nu_engine::documentation::{HelpStyle, get_flags_section};
use nu_protocol::{engine::EngineState, levenshtein_distance, Config}; use nu_protocol::{Config, engine::EngineState, levenshtein_distance};
use nu_utils::IgnoreCaseExt; use nu_utils::IgnoreCaseExt;
use reedline::{Completer, Suggestion}; use reedline::{Completer, Suggestion};
use std::{fmt::Write, sync::Arc}; use std::{fmt::Write, sync::Arc};

View File

@ -1,10 +1,10 @@
use nu_engine::eval_block; use nu_engine::eval_block;
use nu_protocol::{ use nu_protocol::{
BlockId, IntoPipelineData, Span, Value,
debugger::WithoutDebug, debugger::WithoutDebug,
engine::{EngineState, Stack}, engine::{EngineState, Stack},
BlockId, IntoPipelineData, Span, Value,
}; };
use reedline::{menu_functions::parse_selection_char, Completer, Suggestion}; use reedline::{Completer, Suggestion, menu_functions::parse_selection_char};
use std::sync::Arc; use std::sync::Arc;
const SELECTION_CHAR: char = '!'; const SELECTION_CHAR: char = '!';

View File

@ -2,8 +2,9 @@ use crate::NushellPrompt;
use log::{trace, warn}; use log::{trace, warn};
use nu_engine::ClosureEvalOnce; use nu_engine::ClosureEvalOnce;
use nu_protocol::{ use nu_protocol::{
Config, PipelineData, Value,
engine::{EngineState, Stack}, engine::{EngineState, Stack},
report_shell_error, Config, PipelineData, Value, report_shell_error,
}; };
use reedline::Prompt; use reedline::Prompt;

View File

@ -1,19 +1,20 @@
use crate::{menus::NuMenuCompleter, NuHelpCompleter}; use crate::{NuHelpCompleter, menus::NuMenuCompleter};
use crossterm::event::{KeyCode, KeyModifiers}; use crossterm::event::{KeyCode, KeyModifiers};
use nu_ansi_term::Style; use nu_ansi_term::Style;
use nu_color_config::{color_record_to_nustyle, lookup_ansi_color_style}; use nu_color_config::{color_record_to_nustyle, lookup_ansi_color_style};
use nu_engine::eval_block; use nu_engine::eval_block;
use nu_parser::parse; use nu_parser::parse;
use nu_protocol::{ use nu_protocol::{
Config, EditBindings, FromValue, ParsedKeybinding, ParsedMenu, PipelineData, Record,
ShellError, Span, Type, Value,
debugger::WithoutDebug, debugger::WithoutDebug,
engine::{EngineState, Stack, StateWorkingSet}, engine::{EngineState, Stack, StateWorkingSet},
extract_value, Config, EditBindings, FromValue, ParsedKeybinding, ParsedMenu, PipelineData, extract_value,
Record, ShellError, Span, Type, Value,
}; };
use reedline::{ use reedline::{
default_emacs_keybindings, default_vi_insert_keybindings, default_vi_normal_keybindings,
ColumnarMenu, DescriptionMenu, DescriptionMode, EditCommand, IdeMenu, Keybindings, ListMenu, ColumnarMenu, DescriptionMenu, DescriptionMode, EditCommand, IdeMenu, Keybindings, ListMenu,
MenuBuilder, Reedline, ReedlineEvent, ReedlineMenu, MenuBuilder, Reedline, ReedlineEvent, ReedlineMenu, default_emacs_keybindings,
default_vi_insert_keybindings, default_vi_normal_keybindings,
}; };
use std::sync::Arc; use std::sync::Arc;

View File

@ -6,12 +6,12 @@ use crate::prompt_update::{
VSCODE_PRE_EXECUTION_MARKER, VSCODE_PRE_EXECUTION_MARKER,
}; };
use crate::{ use crate::{
NuHighlighter, NuValidator, NushellPrompt,
completions::NuCompleter, completions::NuCompleter,
nu_highlight::NoOpHighlighter, nu_highlight::NoOpHighlighter,
prompt_update, prompt_update,
reedline_config::{add_menus, create_keybindings, KeybindingsMode}, reedline_config::{KeybindingsMode, add_menus, create_keybindings},
util::eval_source, util::eval_source,
NuHighlighter, NuValidator, NushellPrompt,
}; };
use crossterm::cursor::SetCursorStyle; use crossterm::cursor::SetCursorStyle;
use log::{error, trace, warn}; use log::{error, trace, warn};
@ -24,13 +24,13 @@ use nu_engine::exit::cleanup_exit;
use nu_parser::{lex, parse, trim_quotes_str}; use nu_parser::{lex, parse, trim_quotes_str};
use nu_protocol::shell_error::io::IoError; use nu_protocol::shell_error::io::IoError;
use nu_protocol::{ use nu_protocol::{
HistoryConfig, HistoryFileFormat, PipelineData, ShellError, Span, Spanned, Value,
config::NuCursorShape, config::NuCursorShape,
engine::{EngineState, Stack, StateWorkingSet}, engine::{EngineState, Stack, StateWorkingSet},
report_shell_error, HistoryConfig, HistoryFileFormat, PipelineData, ShellError, Span, Spanned, report_shell_error,
Value,
}; };
use nu_utils::{ use nu_utils::{
filesystem::{have_permission, PermissionResult}, filesystem::{PermissionResult, have_permission},
perf, perf,
}; };
use reedline::{ use reedline::{
@ -42,7 +42,7 @@ use std::{
collections::HashMap, collections::HashMap,
env::temp_dir, env::temp_dir,
io::{self, IsTerminal, Write}, io::{self, IsTerminal, Write},
panic::{catch_unwind, AssertUnwindSafe}, panic::{AssertUnwindSafe, catch_unwind},
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::Arc, sync::Arc,
time::{Duration, Instant}, time::{Duration, Instant},
@ -1451,7 +1451,7 @@ fn are_session_ids_in_sync() {
#[cfg(test)] #[cfg(test)]
mod test_auto_cd { mod test_auto_cd {
use super::{do_auto_cd, escape_special_vscode_bytes, parse_operation, ReplOperation}; use super::{ReplOperation, do_auto_cd, escape_special_vscode_bytes, parse_operation};
use nu_path::AbsolutePath; use nu_path::AbsolutePath;
use nu_protocol::engine::{EngineState, Stack}; use nu_protocol::engine::{EngineState, Stack};
use tempfile::tempdir; use tempfile::tempdir;

View File

@ -2,11 +2,11 @@ use log::trace;
use nu_ansi_term::Style; use nu_ansi_term::Style;
use nu_color_config::{get_matching_brackets_style, get_shape_color}; use nu_color_config::{get_matching_brackets_style, get_shape_color};
use nu_engine::env; use nu_engine::env;
use nu_parser::{flatten_block, parse, FlatShape}; use nu_parser::{FlatShape, flatten_block, parse};
use nu_protocol::{ use nu_protocol::{
Span,
ast::{Block, Expr, Expression, PipelineRedirection, RecordItem}, ast::{Block, Expr, Expression, PipelineRedirection, RecordItem},
engine::{EngineState, Stack, StateWorkingSet}, engine::{EngineState, Stack, StateWorkingSet},
Span,
}; };
use reedline::{Highlighter, StyledText}; use reedline::{Highlighter, StyledText};
use std::sync::Arc; use std::sync::Arc;

View File

@ -2,13 +2,13 @@
use nu_cmd_base::hook::eval_hook; use nu_cmd_base::hook::eval_hook;
use nu_engine::{eval_block, eval_block_with_early_return}; use nu_engine::{eval_block, eval_block_with_early_return};
use nu_parser::{lex, parse, unescape_unquote_string, Token, TokenContents}; use nu_parser::{Token, TokenContents, lex, parse, unescape_unquote_string};
use nu_protocol::{ use nu_protocol::{
PipelineData, ShellError, Span, Value,
cli_error::report_compile_error, cli_error::report_compile_error,
debugger::WithoutDebug, debugger::WithoutDebug,
engine::{EngineState, Stack, StateWorkingSet}, engine::{EngineState, Stack, StateWorkingSet},
report_parse_error, report_parse_warning, report_shell_error, PipelineData, ShellError, Span, report_parse_error, report_parse_warning, report_shell_error,
Value,
}; };
#[cfg(windows)] #[cfg(windows)]
use nu_utils::enable_vt_processing; use nu_utils::enable_vt_processing;

View File

@ -1,7 +1,7 @@
use nu_parser::parse; use nu_parser::parse;
use nu_protocol::{ use nu_protocol::{
engine::{EngineState, StateWorkingSet},
ParseError, ParseError,
engine::{EngineState, StateWorkingSet},
}; };
use reedline::{ValidationResult, Validator}; use reedline::{ValidationResult, Validator};
use std::sync::Arc; use std::sync::Arc;

View File

@ -1,5 +1,5 @@
use nu_protocol::HistoryFileFormat; use nu_protocol::HistoryFileFormat;
use nu_test_support::{nu, Outcome}; use nu_test_support::{Outcome, nu};
use reedline::{ use reedline::{
FileBackedHistory, History, HistoryItem, HistoryItemId, ReedlineError, SearchQuery, FileBackedHistory, History, HistoryItem, HistoryItemId, ReedlineError, SearchQuery,
SqliteBackedHistory, SqliteBackedHistory,

View File

@ -1,8 +1,8 @@
pub mod support; pub mod support;
use std::{ use std::{
fs::{read_dir, FileType, ReadDir}, fs::{FileType, ReadDir, read_dir},
path::{PathBuf, MAIN_SEPARATOR}, path::{MAIN_SEPARATOR, PathBuf},
sync::Arc, sync::Arc,
}; };
@ -10,7 +10,7 @@ use nu_cli::NuCompleter;
use nu_engine::eval_block; use nu_engine::eval_block;
use nu_parser::parse; use nu_parser::parse;
use nu_path::expand_tilde; use nu_path::expand_tilde;
use nu_protocol::{debugger::WithoutDebug, engine::StateWorkingSet, Config, PipelineData}; use nu_protocol::{Config, PipelineData, debugger::WithoutDebug, engine::StateWorkingSet};
use nu_std::load_standard_library; use nu_std::load_standard_library;
use reedline::{Completer, Suggestion}; use reedline::{Completer, Suggestion};
use rstest::{fixture, rstest}; use rstest::{fixture, rstest};

View File

@ -2,9 +2,9 @@ use nu_engine::eval_block;
use nu_parser::parse; use nu_parser::parse;
use nu_path::{AbsolutePathBuf, PathBuf}; use nu_path::{AbsolutePathBuf, PathBuf};
use nu_protocol::{ use nu_protocol::{
PipelineData, ShellError, Span, Value,
debugger::WithoutDebug, debugger::WithoutDebug,
engine::{EngineState, Stack, StateWorkingSet}, engine::{EngineState, Stack, StateWorkingSet},
PipelineData, ShellError, Span, Value,
}; };
use nu_test_support::fs; use nu_test_support::fs;
use reedline::Suggestion; use reedline::Suggestion;
@ -273,13 +273,15 @@ pub fn merge_input(
engine_state.merge_delta(delta)?; engine_state.merge_delta(delta)?;
assert!(eval_block::<WithoutDebug>( assert!(
engine_state, eval_block::<WithoutDebug>(
stack, engine_state,
&block, stack,
PipelineData::Value(Value::nothing(Span::unknown()), None), &block,
) PipelineData::Value(Value::nothing(Span::unknown()), None),
.is_ok()); )
.is_ok()
);
// Merge environment into the permanent state // Merge environment into the permanent state
engine_state.merge_env(stack) engine_state.merge_env(stack)

View File

@ -1,7 +1,7 @@
[package] [package]
authors = ["The Nushell Project Developers"] authors = ["The Nushell Project Developers"]
description = "The foundation tools to build Nushell commands." description = "The foundation tools to build Nushell commands."
edition = "2021" edition = "2024"
license = "MIT" license = "MIT"
name = "nu-cmd-base" name = "nu-cmd-base"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-base" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-base"

View File

@ -1,4 +1,4 @@
use indexmap::{indexset, IndexSet}; use indexmap::{IndexSet, indexset};
use nu_protocol::Value; use nu_protocol::Value;
pub fn merge_descriptors(values: &[Value]) -> Vec<String> { pub fn merge_descriptors(values: &[Value]) -> Vec<String> {

View File

@ -2,10 +2,10 @@ use miette::Result;
use nu_engine::{eval_block, eval_block_with_early_return}; use nu_engine::{eval_block, eval_block_with_early_return};
use nu_parser::parse; use nu_parser::parse;
use nu_protocol::{ use nu_protocol::{
PipelineData, PositionalArg, ShellError, Span, Type, Value, VarId,
cli_error::{report_parse_error, report_shell_error}, cli_error::{report_parse_error, report_shell_error},
debugger::WithoutDebug, debugger::WithoutDebug,
engine::{Closure, EngineState, Stack, StateWorkingSet}, engine::{Closure, EngineState, Stack, StateWorkingSet},
PipelineData, PositionalArg, ShellError, Span, Type, Value, VarId,
}; };
use std::{collections::HashMap, sync::Arc}; use std::{collections::HashMap, sync::Arc};

View File

@ -1,4 +1,4 @@
use nu_protocol::{ast::CellPath, PipelineData, ShellError, Signals, Span, Value}; use nu_protocol::{PipelineData, ShellError, Signals, Span, Value, ast::CellPath};
use std::sync::Arc; use std::sync::Arc;
pub trait CmdArgument { pub trait CmdArgument {

View File

@ -1,6 +1,6 @@
use nu_protocol::{ use nu_protocol::{
engine::{EngineState, Stack},
Range, ShellError, Span, Value, Range, ShellError, Span, Value,
engine::{EngineState, Stack},
}; };
use std::ops::Bound; use std::ops::Bound;

View File

@ -1,7 +1,7 @@
[package] [package]
authors = ["The Nushell Project Developers"] authors = ["The Nushell Project Developers"]
description = "Nushell's extra commands that are not part of the 1.0 api standard." description = "Nushell's extra commands that are not part of the 1.0 api standard."
edition = "2021" edition = "2024"
license = "MIT" license = "MIT"
name = "nu-cmd-extra" name = "nu-cmd-extra"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-extra" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-extra"

View File

@ -16,8 +16,8 @@ mod test_examples {
}; };
use nu_protocol::{ use nu_protocol::{
engine::{Command, EngineState, StateWorkingSet},
Type, Type,
engine::{Command, EngineState, StateWorkingSet},
}; };
use std::collections::HashSet; use std::collections::HashSet;

View File

@ -65,7 +65,7 @@ impl Command for BitsAnd {
return Err(ShellError::TypeMismatch { return Err(ShellError::TypeMismatch {
err_message: "Endian must be one of native, little, big".to_string(), err_message: "Endian must be one of native, little, big".to_string(),
span: endian.span, span: endian.span,
}) });
} }
} }
} else { } else {
@ -113,8 +113,7 @@ impl Command for BitsAnd {
])), ])),
}, },
Example { Example {
description: description: "Apply bitwise and to binary data of varying lengths with specified endianness",
"Apply bitwise and to binary data of varying lengths with specified endianness",
example: "0x[c0 ff ee] | bits and 0x[ff] --endian big", example: "0x[c0 ff ee] | bits and 0x[ff] --endian big",
result: Some(Value::test_binary(vec![0x00, 0x00, 0xee])), result: Some(Value::test_binary(vec![0x00, 0x00, 0xee])),
}, },

View File

@ -1,5 +1,5 @@
use super::{get_number_bytes, NumberBytes}; use super::{NumberBytes, get_number_bytes};
use nu_cmd_base::input_handler::{operate, CmdArgument}; use nu_cmd_base::input_handler::{CmdArgument, operate};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
#[derive(Clone)] #[derive(Clone)]
@ -100,8 +100,7 @@ impl Command for BitsNot {
)), )),
}, },
Example { Example {
description: description: "Apply logical negation to a list of numbers, treat input as 2 bytes number",
"Apply logical negation to a list of numbers, treat input as 2 bytes number",
example: "[4 3 2] | bits not --number-bytes 2", example: "[4 3 2] | bits not --number-bytes 2",
result: Some(Value::list( result: Some(Value::list(
vec![ vec![
@ -113,8 +112,7 @@ impl Command for BitsNot {
)), )),
}, },
Example { Example {
description: description: "Apply logical negation to a list of numbers, treat input as signed number",
"Apply logical negation to a list of numbers, treat input as signed number",
example: "[4 3 2] | bits not --signed", example: "[4 3 2] | bits not --signed",
result: Some(Value::list( result: Some(Value::list(
vec![ vec![

View File

@ -66,7 +66,7 @@ impl Command for BitsOr {
return Err(ShellError::TypeMismatch { return Err(ShellError::TypeMismatch {
err_message: "Endian must be one of native, little, big".to_string(), err_message: "Endian must be one of native, little, big".to_string(),
span: endian.span, span: endian.span,
}) });
} }
} }
} else { } else {
@ -106,8 +106,7 @@ impl Command for BitsOr {
result: Some(Value::test_binary(vec![0xca, 0xfe])), result: Some(Value::test_binary(vec![0xca, 0xfe])),
}, },
Example { Example {
description: description: "Apply bitwise or to binary data of varying lengths with specified endianness",
"Apply bitwise or to binary data of varying lengths with specified endianness",
example: "0x[c0 ff ee] | bits or 0x[ff] --endian big", example: "0x[c0 ff ee] | bits or 0x[ff] --endian big",
result: Some(Value::test_binary(vec![0xc0, 0xff, 0xff])), result: Some(Value::test_binary(vec![0xc0, 0xff, 0xff])),
}, },

View File

@ -1,5 +1,5 @@
use super::{get_input_num_type, get_number_bytes, InputNumType, NumberBytes}; use super::{InputNumType, NumberBytes, get_input_num_type, get_number_bytes};
use nu_cmd_base::input_handler::{operate, CmdArgument}; use nu_cmd_base::input_handler::{CmdArgument, operate};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
struct Arguments { struct Arguments {
@ -222,7 +222,8 @@ fn rotate_bytes_and_bits_left(data: &[u8], byte_shift: usize, bit_shift: usize)
debug_assert!(byte_shift < data.len()); debug_assert!(byte_shift < data.len());
debug_assert!( debug_assert!(
(1..8).contains(&bit_shift), (1..8).contains(&bit_shift),
"Bit shifts of 0 can't be handled by this impl and everything else should be part of the byteshift"); "Bit shifts of 0 can't be handled by this impl and everything else should be part of the byteshift"
);
let mut bytes = Vec::with_capacity(data.len()); let mut bytes = Vec::with_capacity(data.len());
let mut next_index = byte_shift; let mut next_index = byte_shift;
for _ in 0..data.len() { for _ in 0..data.len() {

View File

@ -1,5 +1,5 @@
use super::{get_input_num_type, get_number_bytes, InputNumType, NumberBytes}; use super::{InputNumType, NumberBytes, get_input_num_type, get_number_bytes};
use nu_cmd_base::input_handler::{operate, CmdArgument}; use nu_cmd_base::input_handler::{CmdArgument, operate};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
struct Arguments { struct Arguments {

View File

@ -1,6 +1,6 @@
use super::{get_input_num_type, get_number_bytes, InputNumType, NumberBytes}; use super::{InputNumType, NumberBytes, get_input_num_type, get_number_bytes};
use itertools::Itertools; use itertools::Itertools;
use nu_cmd_base::input_handler::{operate, CmdArgument}; use nu_cmd_base::input_handler::{CmdArgument, operate};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
use std::iter; use std::iter;
@ -237,7 +237,8 @@ fn shift_bytes_left(data: &[u8], byte_shift: usize) -> Vec<u8> {
fn shift_bytes_and_bits_left(data: &[u8], byte_shift: usize, bit_shift: usize) -> Vec<u8> { fn shift_bytes_and_bits_left(data: &[u8], byte_shift: usize, bit_shift: usize) -> Vec<u8> {
use itertools::Position::*; use itertools::Position::*;
debug_assert!((1..8).contains(&bit_shift), debug_assert!(
(1..8).contains(&bit_shift),
"Bit shifts of 0 can't be handled by this impl and everything else should be part of the byteshift" "Bit shifts of 0 can't be handled by this impl and everything else should be part of the byteshift"
); );
data.iter() data.iter()

View File

@ -1,5 +1,5 @@
use super::{get_input_num_type, get_number_bytes, InputNumType, NumberBytes}; use super::{InputNumType, NumberBytes, get_input_num_type, get_number_bytes};
use nu_cmd_base::input_handler::{operate, CmdArgument}; use nu_cmd_base::input_handler::{CmdArgument, operate};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
struct Arguments { struct Arguments {

View File

@ -66,7 +66,7 @@ impl Command for BitsXor {
return Err(ShellError::TypeMismatch { return Err(ShellError::TypeMismatch {
err_message: "Endian must be one of native, little, big".to_string(), err_message: "Endian must be one of native, little, big".to_string(),
span: endian.span, span: endian.span,
}) });
} }
} }
} else { } else {
@ -106,8 +106,7 @@ impl Command for BitsXor {
result: Some(Value::test_binary(vec![0x70, 0x40])), result: Some(Value::test_binary(vec![0x70, 0x40])),
}, },
Example { Example {
description: description: "Apply bitwise xor to binary data of varying lengths with specified endianness",
"Apply bitwise xor to binary data of varying lengths with specified endianness",
example: "0x[ca fe] | bits xor 0x[aa] --endian big", example: "0x[ca fe] | bits xor 0x[aa] --endian big",
result: Some(Value::test_binary(vec![0xca, 0x54])), result: Some(Value::test_binary(vec![0xca, 0x54])),
}, },

View File

@ -1,4 +1,4 @@
use nu_engine::{command_prelude::*, ClosureEval, ClosureEvalOnce}; use nu_engine::{ClosureEval, ClosureEvalOnce, command_prelude::*};
use nu_protocol::engine::Closure; use nu_protocol::engine::Closure;
#[derive(Clone)] #[derive(Clone)]

View File

@ -1,4 +1,4 @@
use super::{vertical_rotate_value, VerticalDirection}; use super::{VerticalDirection, vertical_rotate_value};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
#[derive(Clone)] #[derive(Clone)]

View File

@ -1,4 +1,4 @@
use super::{horizontal_rotate_value, HorizontalDirection}; use super::{HorizontalDirection, horizontal_rotate_value};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
#[derive(Clone)] #[derive(Clone)]

View File

@ -1,4 +1,4 @@
use super::{horizontal_rotate_value, HorizontalDirection}; use super::{HorizontalDirection, horizontal_rotate_value};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
#[derive(Clone)] #[derive(Clone)]

View File

@ -1,4 +1,4 @@
use super::{vertical_rotate_value, VerticalDirection}; use super::{VerticalDirection, vertical_rotate_value};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
#[derive(Clone)] #[derive(Clone)]

View File

@ -36,104 +36,93 @@ impl Command for Rotate {
description: "Rotate a record clockwise, producing a table (like `transpose` but with column order reversed)", description: "Rotate a record clockwise, producing a table (like `transpose` but with column order reversed)",
example: "{a:1, b:2} | rotate", example: "{a:1, b:2} | rotate",
result: Some(Value::test_list(vec![ result: Some(Value::test_list(vec![
Value::test_record(record! { Value::test_record(record! {
"column0" => Value::test_int(1), "column0" => Value::test_int(1),
"column1" => Value::test_string("a"), "column1" => Value::test_string("a"),
}), }),
Value::test_record(record! { Value::test_record(record! {
"column0" => Value::test_int(2), "column0" => Value::test_int(2),
"column1" => Value::test_string("b"), "column1" => Value::test_string("b"),
}), }),
], ])),
)),
}, },
Example { Example {
description: "Rotate 2x3 table clockwise", description: "Rotate 2x3 table clockwise",
example: "[[a b]; [1 2] [3 4] [5 6]] | rotate", example: "[[a b]; [1 2] [3 4] [5 6]] | rotate",
result: Some(Value::test_list( result: Some(Value::test_list(vec![
vec![ Value::test_record(record! {
Value::test_record(record! { "column0" => Value::test_int(5),
"column0" => Value::test_int(5), "column1" => Value::test_int(3),
"column1" => Value::test_int(3), "column2" => Value::test_int(1),
"column2" => Value::test_int(1), "column3" => Value::test_string("a"),
"column3" => Value::test_string("a"), }),
}), Value::test_record(record! {
Value::test_record(record! { "column0" => Value::test_int(6),
"column0" => Value::test_int(6), "column1" => Value::test_int(4),
"column1" => Value::test_int(4), "column2" => Value::test_int(2),
"column2" => Value::test_int(2), "column3" => Value::test_string("b"),
"column3" => Value::test_string("b"), }),
}), ])),
],
)),
}, },
Example { Example {
description: "Rotate table clockwise and change columns names", description: "Rotate table clockwise and change columns names",
example: "[[a b]; [1 2]] | rotate col_a col_b", example: "[[a b]; [1 2]] | rotate col_a col_b",
result: Some(Value::test_list( result: Some(Value::test_list(vec![
vec![ Value::test_record(record! {
Value::test_record(record! { "col_a" => Value::test_int(1),
"col_a" => Value::test_int(1), "col_b" => Value::test_string("a"),
"col_b" => Value::test_string("a"), }),
}), Value::test_record(record! {
Value::test_record(record! { "col_a" => Value::test_int(2),
"col_a" => Value::test_int(2), "col_b" => Value::test_string("b"),
"col_b" => Value::test_string("b"), }),
}), ])),
],
)),
}, },
Example { Example {
description: "Rotate table counter clockwise", description: "Rotate table counter clockwise",
example: "[[a b]; [1 2]] | rotate --ccw", example: "[[a b]; [1 2]] | rotate --ccw",
result: Some(Value::test_list( result: Some(Value::test_list(vec![
vec![ Value::test_record(record! {
Value::test_record(record! { "column0" => Value::test_string("b"),
"column0" => Value::test_string("b"), "column1" => Value::test_int(2),
"column1" => Value::test_int(2), }),
}), Value::test_record(record! {
Value::test_record(record! { "column0" => Value::test_string("a"),
"column0" => Value::test_string("a"), "column1" => Value::test_int(1),
"column1" => Value::test_int(1), }),
}), ])),
],
)),
}, },
Example { Example {
description: "Rotate table counter-clockwise", description: "Rotate table counter-clockwise",
example: "[[a b]; [1 2] [3 4] [5 6]] | rotate --ccw", example: "[[a b]; [1 2] [3 4] [5 6]] | rotate --ccw",
result: Some(Value::test_list( result: Some(Value::test_list(vec![
vec![ Value::test_record(record! {
Value::test_record(record! { "column0" => Value::test_string("b"),
"column0" => Value::test_string("b"), "column1" => Value::test_int(2),
"column1" => Value::test_int(2), "column2" => Value::test_int(4),
"column2" => Value::test_int(4), "column3" => Value::test_int(6),
"column3" => Value::test_int(6), }),
}), Value::test_record(record! {
Value::test_record(record! { "column0" => Value::test_string("a"),
"column0" => Value::test_string("a"), "column1" => Value::test_int(1),
"column1" => Value::test_int(1), "column2" => Value::test_int(3),
"column2" => Value::test_int(3), "column3" => Value::test_int(5),
"column3" => Value::test_int(5), }),
}), ])),
],
)),
}, },
Example { Example {
description: "Rotate table counter-clockwise and change columns names", description: "Rotate table counter-clockwise and change columns names",
example: "[[a b]; [1 2]] | rotate --ccw col_a col_b", example: "[[a b]; [1 2]] | rotate --ccw col_a col_b",
result: Some(Value::test_list( result: Some(Value::test_list(vec![
vec![ Value::test_record(record! {
Value::test_record(record! { "col_a" => Value::test_string("b"),
"col_a" => Value::test_string("b"), "col_b" => Value::test_int(2),
"col_b" => Value::test_int(2), }),
}), Value::test_record(record! {
Value::test_record(record! { "col_a" => Value::test_string("a"),
"col_a" => Value::test_string("a"), "col_b" => Value::test_int(1),
"col_b" => Value::test_int(1), }),
}), ])),
],
)),
}, },
] ]
} }

View File

@ -1,5 +1,5 @@
use nu_engine::{command_prelude::*, ClosureEval}; use nu_engine::{ClosureEval, command_prelude::*};
use nu_protocol::{engine::Closure, PipelineIterator}; use nu_protocol::{PipelineIterator, engine::Closure};
use std::collections::HashSet; use std::collections::HashSet;
#[derive(Clone)] #[derive(Clone)]

View File

@ -267,7 +267,7 @@ fn to_html(
span: Some(theme_span), span: Some(theme_span),
help: None, help: None,
inner: vec![], inner: vec![],
}) });
} }
}; };

View File

@ -1,4 +1,4 @@
use nu_ansi_term::{build_all_gradient_text, gradient::TargetGround, Gradient, Rgb}; use nu_ansi_term::{Gradient, Rgb, build_all_gradient_text, gradient::TargetGround};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
#[derive(Clone)] #[derive(Clone)]
@ -70,29 +70,25 @@ impl Command for SubCommand {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![ vec![
Example { Example {
description: "draw text in a gradient with foreground start and end colors", description: "draw text in a gradient with foreground start and end colors",
example: example: "'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff' --fgend '0xe81cff'",
"'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff' --fgend '0xe81cff'", result: None,
result: None, },
}, Example {
Example { description: "draw text in a gradient with foreground start and end colors and background start and end colors",
description: "draw text in a gradient with foreground start and end colors and background start and end colors", example: "'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff' --fgend '0xe81cff' --bgstart '0xe81cff' --bgend '0x40c9ff'",
example: result: None,
"'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff' --fgend '0xe81cff' --bgstart '0xe81cff' --bgend '0x40c9ff'", },
result: None, Example {
}, description: "draw text in a gradient by specifying foreground start color - end color is assumed to be black",
Example { example: "'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff'",
description: "draw text in a gradient by specifying foreground start color - end color is assumed to be black", result: None,
example: },
"'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff'", Example {
result: None, description: "draw text in a gradient by specifying foreground end color - start color is assumed to be black",
}, example: "'Hello, Nushell! This is a gradient.' | ansi gradient --fgend '0xe81cff'",
Example { result: None,
description: "draw text in a gradient by specifying foreground end color - start color is assumed to be black", },
example:
"'Hello, Nushell! This is a gradient.' | ansi gradient --fgend '0xe81cff'",
result: None,
},
] ]
} }
} }
@ -300,7 +296,7 @@ fn action(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{action, SubCommand}; use super::{SubCommand, action};
use nu_ansi_term::Rgb; use nu_ansi_term::Rgb;
use nu_protocol::{Span, Value}; use nu_protocol::{Span, Value};
@ -314,7 +310,9 @@ mod tests {
#[test] #[test]
fn test_fg_gradient() { fn test_fg_gradient() {
let input_string = Value::test_string("Hello, World!"); let input_string = Value::test_string("Hello, World!");
let expected = Value::test_string("\u{1b}[38;2;64;201;255mH\u{1b}[38;2;76;187;254me\u{1b}[38;2;89;174;254ml\u{1b}[38;2;102;160;254ml\u{1b}[38;2;115;147;254mo\u{1b}[38;2;128;133;254m,\u{1b}[38;2;141;120;254m \u{1b}[38;2;153;107;254mW\u{1b}[38;2;166;94;254mo\u{1b}[38;2;179;80;254mr\u{1b}[38;2;192;67;254ml\u{1b}[38;2;205;53;254md\u{1b}[38;2;218;40;254m!\u{1b}[0m"); let expected = Value::test_string(
"\u{1b}[38;2;64;201;255mH\u{1b}[38;2;76;187;254me\u{1b}[38;2;89;174;254ml\u{1b}[38;2;102;160;254ml\u{1b}[38;2;115;147;254mo\u{1b}[38;2;128;133;254m,\u{1b}[38;2;141;120;254m \u{1b}[38;2;153;107;254mW\u{1b}[38;2;166;94;254mo\u{1b}[38;2;179;80;254mr\u{1b}[38;2;192;67;254ml\u{1b}[38;2;205;53;254md\u{1b}[38;2;218;40;254m!\u{1b}[0m",
);
let fg_start = Rgb::from_hex_string("0x40c9ff".to_string()); let fg_start = Rgb::from_hex_string("0x40c9ff".to_string());
let fg_end = Rgb::from_hex_string("0xe81cff".to_string()); let fg_end = Rgb::from_hex_string("0xe81cff".to_string());
let actual = action( let actual = action(

View File

@ -1,9 +1,9 @@
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
use nu_cmd_base::input_handler::{operate, CmdArgument}; use nu_cmd_base::input_handler::{CmdArgument, operate};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
use nu_protocol::{shell_error::io::IoError, Signals}; use nu_protocol::{Signals, shell_error::io::IoError};
use num_traits::ToPrimitive; use num_traits::ToPrimitive;
struct Arguments { struct Arguments {
@ -68,42 +68,33 @@ impl Command for FormatBits {
Example { Example {
description: "convert a binary value into a string, padded to 8 places with 0s", description: "convert a binary value into a string, padded to 8 places with 0s",
example: "0x[1] | format bits", example: "0x[1] | format bits",
result: Some(Value::string("00000001", result: Some(Value::string("00000001", Span::test_data())),
Span::test_data(),
)),
}, },
Example { Example {
description: "convert an int into a string, padded to 8 places with 0s", description: "convert an int into a string, padded to 8 places with 0s",
example: "1 | format bits", example: "1 | format bits",
result: Some(Value::string("00000001", result: Some(Value::string("00000001", Span::test_data())),
Span::test_data(),
)),
}, },
Example { Example {
description: "convert a filesize value into a string, padded to 8 places with 0s", description: "convert a filesize value into a string, padded to 8 places with 0s",
example: "1b | format bits", example: "1b | format bits",
result: Some(Value::string("00000001", result: Some(Value::string("00000001", Span::test_data())),
Span::test_data(),
)),
}, },
Example { Example {
description: "convert a duration value into a string, padded to 8 places with 0s", description: "convert a duration value into a string, padded to 8 places with 0s",
example: "1ns | format bits", example: "1ns | format bits",
result: Some(Value::string("00000001", result: Some(Value::string("00000001", Span::test_data())),
Span::test_data(),
)),
}, },
Example { Example {
description: "convert a boolean value into a string, padded to 8 places with 0s", description: "convert a boolean value into a string, padded to 8 places with 0s",
example: "true | format bits", example: "true | format bits",
result: Some(Value::string("00000001", result: Some(Value::string("00000001", Span::test_data())),
Span::test_data(),
)),
}, },
Example { Example {
description: "convert a string into a raw binary string, padded with 0s to 8 places", description: "convert a string into a raw binary string, padded with 0s to 8 places",
example: "'nushell.sh' | format bits", example: "'nushell.sh' | format bits",
result: Some(Value::string("01101110 01110101 01110011 01101000 01100101 01101100 01101100 00101110 01110011 01101000", result: Some(Value::string(
"01101110 01110101 01110011 01101000 01100101 01101100 01101100 00101110 01110011 01101000",
Span::test_data(), Span::test_data(),
)), )),
}, },

View File

@ -1,5 +1,5 @@
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
use nu_protocol::{ast::PathMember, engine::StateWorkingSet, Config, ListStream}; use nu_protocol::{Config, ListStream, ast::PathMember, engine::StateWorkingSet};
#[derive(Clone)] #[derive(Clone)]
pub struct FormatPattern; pub struct FormatPattern;
@ -214,7 +214,7 @@ fn format(
wrong_type: val.get_type().to_string(), wrong_type: val.get_type().to_string(),
dst_span: head_span, dst_span: head_span,
src_span: val.span(), src_span: val.span(),
}) });
} }
} }
} }

View File

@ -1,4 +1,4 @@
use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs}; use nu_cmd_base::input_handler::{CellPathOnlyArgs, operate};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
#[derive(Clone)] #[derive(Clone)]

View File

@ -14,7 +14,7 @@ pub use snake_case::StrSnakeCase;
pub use str_::Str; pub use str_::Str;
pub use title_case::StrTitleCase; pub use title_case::StrTitleCase;
use nu_cmd_base::input_handler::{operate as general_operate, CmdArgument}; use nu_cmd_base::input_handler::{CmdArgument, operate as general_operate};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
struct Arguments<F: Fn(&str) -> String + Send + Sync + 'static> { struct Arguments<F: Fn(&str) -> String + Send + Sync + 'static> {

View File

@ -3,7 +3,7 @@ authors = ["The Nushell Project Developers"]
build = "build.rs" build = "build.rs"
description = "Nushell's core language commands" description = "Nushell's core language commands"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-lang" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-lang"
edition = "2021" edition = "2024"
license = "MIT" license = "MIT"
name = "nu-cmd-lang" name = "nu-cmd-lang"
version = "0.104.1" version = "0.104.1"

View File

@ -39,7 +39,9 @@ impl Command for Break {
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
// This is compiled specially by the IR compiler. The code here is never used when // This is compiled specially by the IR compiler. The code here is never used when
// running in IR mode. // running in IR mode.
eprintln!("Tried to execute 'run' for the 'break' command: this code path should never be reached in IR mode"); eprintln!(
"Tried to execute 'run' for the 'break' command: this code path should never be reached in IR mode"
);
unreachable!() unreachable!()
} }

View File

@ -1,5 +1,5 @@
use nu_engine::{command_prelude::*, get_eval_block, redirect_env}; use nu_engine::{command_prelude::*, get_eval_block, redirect_env};
use nu_protocol::{engine::Closure, DataSource, PipelineMetadata}; use nu_protocol::{DataSource, PipelineMetadata, engine::Closure};
#[derive(Clone)] #[derive(Clone)]
pub struct Collect; pub struct Collect;

View File

@ -48,7 +48,9 @@ impl Command for Const {
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
// This is compiled specially by the IR compiler. The code here is never used when // This is compiled specially by the IR compiler. The code here is never used when
// running in IR mode. // running in IR mode.
eprintln!("Tried to execute 'run' for the 'const' command: this code path should never be reached in IR mode"); eprintln!(
"Tried to execute 'run' for the 'const' command: this code path should never be reached in IR mode"
);
unreachable!() unreachable!()
} }

View File

@ -38,7 +38,9 @@ impl Command for Continue {
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
// This is compiled specially by the IR compiler. The code here is never used when // This is compiled specially by the IR compiler. The code here is never used when
// running in IR mode. // running in IR mode.
eprintln!("Tried to execute 'run' for the 'continue' command: this code path should never be reached in IR mode"); eprintln!(
"Tried to execute 'run' for the 'continue' command: this code path should never be reached in IR mode"
);
unreachable!() unreachable!()
} }

View File

@ -1,7 +1,7 @@
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
use nu_protocol::{ use nu_protocol::{
engine::{Closure, StateWorkingSet},
BlockId, ByteStreamSource, Category, PipelineMetadata, Signature, BlockId, ByteStreamSource, Category, PipelineMetadata, Signature,
engine::{Closure, StateWorkingSet},
}; };
use std::any::type_name; use std::any::type_name;
#[derive(Clone)] #[derive(Clone)]
@ -72,8 +72,7 @@ impl Command for Describe {
}, },
Example { Example {
description: "Describe the type of a record in a detailed way", description: "Describe the type of a record in a detailed way",
example: example: "{shell:'true', uwu:true, features: {bugs:false, multiplatform:true, speed: 10}, fib: [1 1 2 3 5 8], on_save: {|x| $'Saving ($x)'}, first_commit: 2019-05-10, my_duration: (4min + 20sec)} | describe -d",
"{shell:'true', uwu:true, features: {bugs:false, multiplatform:true, speed: 10}, fib: [1 1 2 3 5 8], on_save: {|x| $'Saving ($x)'}, first_commit: 2019-05-10, my_duration: (4min + 20sec)} | describe -d",
result: Some(Value::test_record(record!( result: Some(Value::test_record(record!(
"type" => Value::test_string("record"), "type" => Value::test_string("record"),
"detailed_type" => Value::test_string("record<shell: string, uwu: bool, features: record<bugs: bool, multiplatform: bool, speed: int>, fib: list<int>, on_save: closure, first_commit: datetime, my_duration: duration>"), "detailed_type" => Value::test_string("record<shell: string, uwu: bool, features: record<bugs: bool, multiplatform: bool, speed: int>, fib: list<int>, on_save: closure, first_commit: datetime, my_duration: duration>"),
@ -191,32 +190,32 @@ impl Command for Describe {
Example { Example {
description: "Describe the type of a stream with detailed information", description: "Describe the type of a stream with detailed information",
example: "[1 2 3] | each {|i| echo $i} | describe -d", example: "[1 2 3] | each {|i| echo $i} | describe -d",
result: None // Give "Running external commands not supported" error result: None, // Give "Running external commands not supported" error
// result: Some(Value::test_record(record!( // result: Some(Value::test_record(record!(
// "type" => Value::test_string("stream"), // "type" => Value::test_string("stream"),
// "origin" => Value::test_string("nushell"), // "origin" => Value::test_string("nushell"),
// "subtype" => Value::test_record(record!( // "subtype" => Value::test_record(record!(
// "type" => Value::test_string("list"), // "type" => Value::test_string("list"),
// "length" => Value::test_int(3), // "length" => Value::test_int(3),
// "values" => Value::test_list(vec![ // "values" => Value::test_list(vec![
// Value::test_string("int"), // Value::test_string("int"),
// Value::test_string("int"), // Value::test_string("int"),
// Value::test_string("int"), // Value::test_string("int"),
// ]) // ])
// )) // ))
// ))), // ))),
}, },
Example { Example {
description: "Describe a stream of data, collecting it first", description: "Describe a stream of data, collecting it first",
example: "[1 2 3] | each {|i| echo $i} | describe", example: "[1 2 3] | each {|i| echo $i} | describe",
result: None // Give "Running external commands not supported" error result: None, // Give "Running external commands not supported" error
// result: Some(Value::test_string("list<int> (stream)")), // result: Some(Value::test_string("list<int> (stream)")),
}, },
Example { Example {
description: "Describe the input but do not collect streams", description: "Describe the input but do not collect streams",
example: "[1 2 3] | each {|i| echo $i} | describe --no-collect", example: "[1 2 3] | each {|i| echo $i} | describe --no-collect",
result: None // Give "Running external commands not supported" error result: None, // Give "Running external commands not supported" error
// result: Some(Value::test_string("stream")), // result: Some(Value::test_string("stream")),
}, },
] ]
} }

View File

@ -2,7 +2,7 @@ use nu_engine::{command_prelude::*, get_eval_block_with_early_return, redirect_e
#[cfg(feature = "os")] #[cfg(feature = "os")]
use nu_protocol::process::{ChildPipe, ChildProcess}; use nu_protocol::process::{ChildPipe, ChildProcess};
use nu_protocol::{ use nu_protocol::{
engine::Closure, shell_error::io::IoError, ByteStream, ByteStreamSource, OutDest, ByteStream, ByteStreamSource, OutDest, engine::Closure, shell_error::io::IoError,
}; };
use std::{ use std::{

View File

@ -63,8 +63,7 @@ little reason to use this over just writing the values as-is."#
)), )),
}, },
Example { Example {
description: description: "Returns the piped-in value, by using the special $in variable to obtain it.",
"Returns the piped-in value, by using the special $in variable to obtain it.",
example: "echo $in", example: "echo $in",
result: None, result: None,
}, },

View File

@ -76,8 +76,7 @@ impl Command for ErrorMake {
result: None, result: None,
}, },
Example { Example {
description: description: "Create a custom error for a custom command that shows the span of the argument",
"Create a custom error for a custom command that shows the span of the argument",
example: r#"def foo [x] { example: r#"def foo [x] {
error make { error make {
msg: "this is fishy" msg: "this is fishy"
@ -106,7 +105,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
span: throw_span, span: throw_span,
help: None, help: None,
inner: vec![], inner: vec![],
} };
} }
}; };
@ -119,7 +118,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
span: Some(span), span: Some(span),
help: None, help: None,
inner: vec![], inner: vec![],
} };
} }
None => { None => {
return ShellError::GenericError { return ShellError::GenericError {
@ -128,7 +127,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
span: Some(span), span: Some(span),
help: None, help: None,
inner: vec![], inner: vec![],
} };
} }
}; };
@ -146,7 +145,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
span: Some(span), span: Some(span),
help: None, help: None,
inner: vec![], inner: vec![],
} };
} }
// correct return: no label // correct return: no label
None => { None => {
@ -156,7 +155,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
span: throw_span, span: throw_span,
help, help,
inner: vec![], inner: vec![],
} };
} }
}; };
@ -180,7 +179,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
span: Some(label_span), span: Some(label_span),
help: None, help: None,
inner: vec![], inner: vec![],
} };
} }
None => { None => {
return ShellError::GenericError { return ShellError::GenericError {
@ -189,7 +188,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
span: Some(label_span), span: Some(label_span),
help: None, help: None,
inner: vec![], inner: vec![],
} };
} }
}; };
@ -202,7 +201,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
span: Some(value.span()), span: Some(value.span()),
help: None, help: None,
inner: vec![], inner: vec![],
} };
} }
// correct return: label, no span // correct return: label, no span
None => { None => {
@ -212,7 +211,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
span: throw_span, span: throw_span,
help, help,
inner: vec![], inner: vec![],
} };
} }
}; };

View File

@ -50,7 +50,9 @@ impl Command for For {
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
// This is compiled specially by the IR compiler. The code here is never used when // This is compiled specially by the IR compiler. The code here is never used when
// running in IR mode. // running in IR mode.
eprintln!("Tried to execute 'run' for the 'for' command: this code path should never be reached in IR mode"); eprintln!(
"Tried to execute 'run' for the 'for' command: this code path should never be reached in IR mode"
);
unreachable!() unreachable!()
} }

View File

@ -100,7 +100,9 @@ impl Command for If {
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
// This is compiled specially by the IR compiler. The code here is never used when // This is compiled specially by the IR compiler. The code here is never used when
// running in IR mode. // running in IR mode.
eprintln!("Tried to execute 'run' for the 'if' command: this code path should never be reached in IR mode"); eprintln!(
"Tried to execute 'run' for the 'if' command: this code path should never be reached in IR mode"
);
unreachable!() unreachable!()
} }

View File

@ -1,5 +1,5 @@
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
use nu_protocol::{engine::StateWorkingSet, ByteStreamSource, OutDest}; use nu_protocol::{ByteStreamSource, OutDest, engine::StateWorkingSet};
#[derive(Clone)] #[derive(Clone)]
pub struct Ignore; pub struct Ignore;

View File

@ -48,7 +48,9 @@ impl Command for Let {
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
// This is compiled specially by the IR compiler. The code here is never used when // This is compiled specially by the IR compiler. The code here is never used when
// running in IR mode. // running in IR mode.
eprintln!("Tried to execute 'run' for the 'let' command: this code path should never be reached in IR mode"); eprintln!(
"Tried to execute 'run' for the 'let' command: this code path should never be reached in IR mode"
);
unreachable!() unreachable!()
} }

View File

@ -39,7 +39,9 @@ impl Command for Loop {
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
// This is compiled specially by the IR compiler. The code here is never used when // This is compiled specially by the IR compiler. The code here is never used when
// running in IR mode. // running in IR mode.
eprintln!("Tried to execute 'run' for the 'loop' command: this code path should never be reached in IR mode"); eprintln!(
"Tried to execute 'run' for the 'loop' command: this code path should never be reached in IR mode"
);
unreachable!() unreachable!()
} }

View File

@ -43,7 +43,9 @@ impl Command for Match {
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
// This is compiled specially by the IR compiler. The code here is never used when // This is compiled specially by the IR compiler. The code here is never used when
// running in IR mode. // running in IR mode.
eprintln!("Tried to execute 'run' for the 'match' command: this code path should never be reached in IR mode"); eprintln!(
"Tried to execute 'run' for the 'match' command: this code path should never be reached in IR mode"
);
unreachable!() unreachable!()
} }
@ -56,8 +58,7 @@ impl Command for Match {
}, },
Example { Example {
description: "Match against alternative values", description: "Match against alternative values",
example: example: "match 'three' { 1 | 'one' => '-', 2 | 'two' => '--', 3 | 'three' => '---' }",
"match 'three' { 1 | 'one' => '-', 2 | 'two' => '--', 3 | 'three' => '---' }",
result: Some(Value::test_string("---")), result: Some(Value::test_string("---")),
}, },
Example { Example {

View File

@ -48,7 +48,9 @@ impl Command for Mut {
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
// This is compiled specially by the IR compiler. The code here is never used when // This is compiled specially by the IR compiler. The code here is never used when
// running in IR mode. // running in IR mode.
eprintln!("Tried to execute 'run' for the 'mut' command: this code path should never be reached in IR mode"); eprintln!(
"Tried to execute 'run' for the 'mut' command: this code path should never be reached in IR mode"
);
unreachable!() unreachable!()
} }

View File

@ -76,7 +76,7 @@ impl Command for OverlayHide {
return Err(ShellError::EnvVarNotFoundAtRuntime { return Err(ShellError::EnvVarNotFoundAtRuntime {
envvar_name: name.item, envvar_name: name.item,
span: name.span, span: name.span,
}) });
} }
} }
} }

View File

@ -2,7 +2,7 @@ use nu_engine::{
command_prelude::*, find_in_dirs_env, get_dirs_var_from_call, get_eval_block, redirect_env, command_prelude::*, find_in_dirs_env, get_dirs_var_from_call, get_eval_block, redirect_env,
}; };
use nu_parser::trim_quotes_str; use nu_parser::trim_quotes_str;
use nu_protocol::{ast::Expr, engine::CommandType, ModuleId}; use nu_protocol::{ModuleId, ast::Expr, engine::CommandType};
use std::path::Path; use std::path::Path;

View File

@ -42,7 +42,9 @@ impl Command for Return {
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
// This is compiled specially by the IR compiler. The code here is never used when // This is compiled specially by the IR compiler. The code here is never used when
// running in IR mode. // running in IR mode.
eprintln!("Tried to execute 'run' for the 'return' command: this code path should never be reached in IR mode"); eprintln!(
"Tried to execute 'run' for the 'return' command: this code path should never be reached in IR mode"
);
unreachable!() unreachable!()
} }

View File

@ -49,7 +49,9 @@ impl Command for Try {
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
// This is compiled specially by the IR compiler. The code here is never used when // This is compiled specially by the IR compiler. The code here is never used when
// running in IR mode. // running in IR mode.
eprintln!("Tried to execute 'run' for the 'try' command: this code path should never be reached in IR mode"); eprintln!(
"Tried to execute 'run' for the 'try' command: this code path should never be reached in IR mode"
);
unreachable!(); unreachable!();
} }

View File

@ -48,7 +48,9 @@ impl Command for While {
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
// This is compiled specially by the IR compiler. The code here is never used when // This is compiled specially by the IR compiler. The code here is never used when
// running in IR mode. // running in IR mode.
eprintln!("Tried to execute 'run' for the 'while' command: this code path should never be reached in IR mode"); eprintln!(
"Tried to execute 'run' for the 'while' command: this code path should never be reached in IR mode"
);
unreachable!() unreachable!()
} }

View File

@ -1,7 +1,7 @@
use itertools::Itertools; use itertools::Itertools;
use nu_engine::{command_prelude::*, compile}; use nu_engine::{command_prelude::*, compile};
use nu_protocol::{ use nu_protocol::{
ast::Block, debugger::WithoutDebug, engine::StateWorkingSet, report_shell_error, Range, Range, ast::Block, debugger::WithoutDebug, engine::StateWorkingSet, report_shell_error,
}; };
use std::{ use std::{
sync::Arc, sync::Arc,
@ -163,13 +163,9 @@ pub fn check_example_evaluates_to_expected_output(
let expected = DebuggableValue(expected); let expected = DebuggableValue(expected);
let result = DebuggableValue(&result); let result = DebuggableValue(&result);
assert_eq!( assert_eq!(
result, result, expected,
expected,
"Error: The result of example '{}' for the command '{}' differs from the expected value.\n\nExpected: {:?}\nActual: {:?}\n", "Error: The result of example '{}' for the command '{}' differs from the expected value.\n\nExpected: {:?}\nActual: {:?}\n",
example.description, example.description, cmd_name, expected, result,
cmd_name,
expected,
result,
); );
} }
} }

View File

@ -17,8 +17,8 @@ mod test_examples {
Break, Collect, Def, Describe, Echo, ExportCommand, ExportDef, If, Let, Module, Mut, Use, Break, Collect, Def, Describe, Echo, ExportCommand, ExportDef, If, Let, Module, Mut, Use,
}; };
use nu_protocol::{ use nu_protocol::{
engine::{Command, EngineState, StateWorkingSet},
Type, Value, Type, Value,
engine::{Command, EngineState, StateWorkingSet},
}; };
use std::collections::HashSet; use std::collections::HashSet;

View File

@ -1,4 +1,4 @@
use nu_protocol::{engine::StateWorkingSet, Span}; use nu_protocol::{Span, engine::StateWorkingSet};
use quickcheck_macros::quickcheck; use quickcheck_macros::quickcheck;
#[quickcheck] #[quickcheck]

View File

@ -1,7 +1,7 @@
[package] [package]
authors = ["The Nushell Project Developers"] authors = ["The Nushell Project Developers"]
description = "Commands for managing Nushell plugins." description = "Commands for managing Nushell plugins."
edition = "2021" edition = "2024"
license = "MIT" license = "MIT"
name = "nu-cmd-plugin" name = "nu-cmd-plugin"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-plugin" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-plugin"

View File

@ -2,7 +2,7 @@ use crate::util::{get_plugin_dirs, modify_plugin_file};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
use nu_plugin_engine::{GetPlugin, PersistentPlugin}; use nu_plugin_engine::{GetPlugin, PersistentPlugin};
use nu_protocol::{ use nu_protocol::{
shell_error::io::IoError, PluginGcConfig, PluginIdentity, PluginRegistryItem, RegisteredPlugin, PluginGcConfig, PluginIdentity, PluginRegistryItem, RegisteredPlugin, shell_error::io::IoError,
}; };
use std::{path::PathBuf, sync::Arc}; use std::{path::PathBuf, sync::Arc};

View File

@ -80,8 +80,7 @@ it was already previously registered with `plugin add`.
result: None, result: None,
}, },
Example { Example {
description: description: "Load the commands for the `query` plugin from a custom plugin registry file",
"Load the commands for the `query` plugin from a custom plugin registry file",
example: r#"plugin use --plugin-config local-plugins.msgpackz query"#, example: r#"plugin use --plugin-config local-plugins.msgpackz query"#,
result: None, result: None,
}, },

View File

@ -1,6 +1,6 @@
#[allow(deprecated)] #[allow(deprecated)]
use nu_engine::{command_prelude::*, current_dir}; use nu_engine::{command_prelude::*, current_dir};
use nu_protocol::{engine::StateWorkingSet, shell_error::io::IoError, PluginRegistryFile}; use nu_protocol::{PluginRegistryFile, engine::StateWorkingSet, shell_error::io::IoError};
use std::{ use std::{
fs::{self, File}, fs::{self, File},
path::PathBuf, path::PathBuf,
@ -15,7 +15,7 @@ fn get_plugin_registry_file_path(
#[allow(deprecated)] #[allow(deprecated)]
let cwd = current_dir(engine_state, stack)?; let cwd = current_dir(engine_state, stack)?;
if let Some(ref custom_path) = custom_path { if let Some(custom_path) = custom_path {
Ok(nu_path::expand_path_with(&custom_path.item, cwd, true)) Ok(nu_path::expand_path_with(&custom_path.item, cwd, true))
} else { } else {
engine_state engine_state

View File

@ -2,7 +2,7 @@
authors = ["The Nushell Project Developers"] authors = ["The Nushell Project Developers"]
description = "Color configuration code used by Nushell" description = "Color configuration code used by Nushell"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-color-config" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-color-config"
edition = "2021" edition = "2024"
license = "MIT" license = "MIT"
name = "nu-color-config" name = "nu-color-config"
version = "0.104.1" version = "0.104.1"

View File

@ -1,6 +1,7 @@
use crate::{ use crate::{
NuStyle,
nu_style::{color_from_hex, lookup_style}, nu_style::{color_from_hex, lookup_style},
parse_nustyle, NuStyle, parse_nustyle,
}; };
use nu_ansi_term::Style; use nu_ansi_term::Style;
use nu_protocol::{Record, Value}; use nu_protocol::{Record, Value};
@ -67,11 +68,7 @@ fn get_style_from_value(record: &Record) -> Option<NuStyle> {
} }
} }
if was_set { if was_set { Some(style) } else { None }
Some(style)
} else {
None
}
} }
fn color_string_to_nustyle(color_string: &str) -> Style { fn color_string_to_nustyle(color_string: &str) -> Style {
@ -92,7 +89,7 @@ fn color_string_to_nustyle(color_string: &str) -> Style {
mod tests { mod tests {
use super::*; use super::*;
use nu_ansi_term::{Color, Style}; use nu_ansi_term::{Color, Style};
use nu_protocol::{record, Span, Value}; use nu_protocol::{Span, Value, record};
#[test] #[test]
fn test_color_string_to_nustyle_empty_string() { fn test_color_string_to_nustyle_empty_string() {

View File

@ -47,11 +47,7 @@ fn style_get_attr(s: Style) -> Option<String> {
attrs.push('u'); attrs.push('u');
}; };
if attrs.is_empty() { if attrs.is_empty() { None } else { Some(attrs) }
None
} else {
Some(attrs)
}
} }
fn color_to_string(color: Color) -> Option<String> { fn color_to_string(color: Color) -> Option<String> {

View File

@ -1,9 +1,10 @@
use crate::{color_record_to_nustyle, lookup_ansi_color_style, text_style::Alignment, TextStyle}; use crate::{TextStyle, color_record_to_nustyle, lookup_ansi_color_style, text_style::Alignment};
use nu_ansi_term::{Color, Style}; use nu_ansi_term::{Color, Style};
use nu_engine::ClosureEvalOnce; use nu_engine::ClosureEvalOnce;
use nu_protocol::{ use nu_protocol::{
Span, Value,
engine::{Closure, EngineState, Stack}, engine::{Closure, EngineState, Stack},
report_shell_error, Span, Value, report_shell_error,
}; };
use std::{ use std::{
collections::HashMap, collections::HashMap,
@ -240,9 +241,11 @@ fn test_computable_style_closure_errors() {
]; ];
let actual_repl = nu!(nu_repl_code(&inp)); let actual_repl = nu!(nu_repl_code(&inp));
// Check that the error was printed // Check that the error was printed
assert!(actual_repl assert!(
.err actual_repl
.contains("nu::shell::operator_incompatible_types")); .err
.contains("nu::shell::operator_incompatible_types")
);
// Check that the value was printed // Check that the value was printed
assert!(actual_repl.out.contains("bell")); assert!(actual_repl.out.contains("bell"));
} }

View File

@ -1,7 +1,7 @@
[package] [package]
authors = ["The Nushell Project Developers"] authors = ["The Nushell Project Developers"]
description = "Nushell's built-in commands" description = "Nushell's built-in commands"
edition = "2021" edition = "2024"
license = "MIT" license = "MIT"
name = "nu-command" name = "nu-command"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-command" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-command"

View File

@ -1,4 +1,4 @@
use nu_cmd_base::input_handler::{operate, CmdArgument}; use nu_cmd_base::input_handler::{CmdArgument, operate};
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
struct Arguments { struct Arguments {
@ -86,28 +86,32 @@ impl Command for BytesAdd {
Example { Example {
description: "Add bytes `0x[AA]` to `0x[1F FF AA AA]`", description: "Add bytes `0x[AA]` to `0x[1F FF AA AA]`",
example: "0x[1F FF AA AA] | bytes add 0x[AA]", example: "0x[1F FF AA AA] | bytes add 0x[AA]",
result: Some(Value::binary(vec![0xAA, 0x1F, 0xFF, 0xAA, 0xAA], result: Some(Value::binary(
vec![0xAA, 0x1F, 0xFF, 0xAA, 0xAA],
Span::test_data(), Span::test_data(),
)), )),
}, },
Example { Example {
description: "Add bytes `0x[AA BB]` to `0x[1F FF AA AA]` at index 1", description: "Add bytes `0x[AA BB]` to `0x[1F FF AA AA]` at index 1",
example: "0x[1F FF AA AA] | bytes add 0x[AA BB] --index 1", example: "0x[1F FF AA AA] | bytes add 0x[AA BB] --index 1",
result: Some(Value::binary(vec![0x1F, 0xAA, 0xBB, 0xFF, 0xAA, 0xAA], result: Some(Value::binary(
vec![0x1F, 0xAA, 0xBB, 0xFF, 0xAA, 0xAA],
Span::test_data(), Span::test_data(),
)), )),
}, },
Example { Example {
description: "Add bytes `0x[11]` to `0x[FF AA AA]` at the end", description: "Add bytes `0x[11]` to `0x[FF AA AA]` at the end",
example: "0x[FF AA AA] | bytes add 0x[11] --end", example: "0x[FF AA AA] | bytes add 0x[11] --end",
result: Some(Value::binary(vec![0xFF, 0xAA, 0xAA, 0x11], result: Some(Value::binary(
vec![0xFF, 0xAA, 0xAA, 0x11],
Span::test_data(), Span::test_data(),
)), )),
}, },
Example { Example {
description: "Add bytes `0x[11 22 33]` to `0x[FF AA AA]` at the end, at index 1(the index is start from end)", description: "Add bytes `0x[11 22 33]` to `0x[FF AA AA]` at the end, at index 1(the index is start from end)",
example: "0x[FF AA BB] | bytes add 0x[11 22 33] --end --index 1", example: "0x[FF AA BB] | bytes add 0x[11 22 33] --end --index 1",
result: Some(Value::binary(vec![0xFF, 0xAA, 0x11, 0x22, 0x33, 0xBB], result: Some(Value::binary(
vec![0xFF, 0xAA, 0x11, 0x22, 0x33, 0xBB],
Span::test_data(), Span::test_data(),
)), )),
}, },

Some files were not shown because too many files have changed in this diff Show More