mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Compare commits
85 Commits
Author | SHA1 | Date | |
---|---|---|---|
c74cff213e | |||
2ea5819b02 | |||
1115190a49 | |||
7132c5ad02 | |||
1920ece759 | |||
6f59abaf43 | |||
5f7425a7b4 | |||
1ab9ec3ebc | |||
f2095ed0cc | |||
7e26b4fcc2 | |||
ad95e4cc27 | |||
ee5a18167c | |||
75c9e3e5df | |||
77f10eb270 | |||
42bb42a2e1 | |||
f597380112 | |||
b92b4120dc | |||
de5ad5de19 | |||
64695cd67c | |||
21b3eeed99 | |||
a86a7e6c29 | |||
15421dc45e | |||
9522052063 | |||
ba880277bf | |||
40241e9be6 | |||
34f3da7150 | |||
534287ed65 | |||
913c2b8d1c | |||
aeffa188f0 | |||
543a25599c | |||
7ad0e5541e | |||
c1cc1c82cc | |||
b0b4c3dffd | |||
f3de373c59 | |||
df1fecd2cb | |||
9620e27e4f | |||
072ecec8ca | |||
748d82cec1 | |||
5e5d1ea81b | |||
bb570e42be | |||
3a050864df | |||
8cfa96b4c0 | |||
6f384da57e | |||
f8e63328d8 | |||
5d98a727ca | |||
109f629cb6 | |||
ff6a67d293 | |||
03ae01f11e | |||
697f3c03f1 | |||
1cecb37628 | |||
89436e978b | |||
cd0a52cf00 | |||
c6043eb500 | |||
729373aba0 | |||
f59a6990dc | |||
0f9094ead2 | |||
70f7db14d4 | |||
0cba269d80 | |||
ec2593efb8 | |||
c2283596ac | |||
c9399f5142 | |||
c9c93f5b4d | |||
2264682443 | |||
247c33b6d6 | |||
a6da8ce769 | |||
020e121391 | |||
7d5bd0d6be | |||
87717b9ddd | |||
3c6fac059e | |||
9092fc1b12 | |||
5b557a888e | |||
398b756aee | |||
533c1a89af | |||
84742275a1 | |||
92d968b8c8 | |||
50102bf69b | |||
156232fe08 | |||
0a3761a594 | |||
44dc890124 | |||
6ead98effb | |||
d5f76c02f0 | |||
fd77114d82 | |||
78f52e8b66 | |||
5b01685fc3 | |||
c2b684464f |
1
.github/.typos.toml
vendored
1
.github/.typos.toml
vendored
@ -12,3 +12,4 @@ IIF = "IIF"
|
||||
numer = "numer"
|
||||
ratatui = "ratatui"
|
||||
doas = "doas"
|
||||
wheres = "wheres"
|
||||
|
35
.github/workflows/ci.yml
vendored
35
.github/workflows/ci.yml
vendored
@ -92,6 +92,17 @@ jobs:
|
||||
- name: Tests
|
||||
run: cargo test --workspace --profile ci --exclude nu_plugin_* ${{ matrix.flags }}
|
||||
|
||||
- name: Check for clean repo
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "there are changes";
|
||||
git status --porcelain
|
||||
exit 1
|
||||
else
|
||||
echo "no changes in working directory";
|
||||
fi
|
||||
|
||||
std-lib-and-python-virtualenv:
|
||||
strategy:
|
||||
fail-fast: true
|
||||
@ -117,7 +128,7 @@ jobs:
|
||||
run: nu -c 'use std testing; testing run-tests --path crates/nu-std'
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.10"
|
||||
|
||||
@ -129,6 +140,17 @@ jobs:
|
||||
run: nu scripts/test_virtualenv.nu
|
||||
shell: bash
|
||||
|
||||
- name: Check for clean repo
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "there are changes";
|
||||
git status --porcelain
|
||||
exit 1
|
||||
else
|
||||
echo "no changes in working directory";
|
||||
fi
|
||||
|
||||
plugins:
|
||||
strategy:
|
||||
fail-fast: true
|
||||
@ -150,3 +172,14 @@ jobs:
|
||||
|
||||
- name: Tests
|
||||
run: cargo test --profile ci --package nu_plugin_*
|
||||
|
||||
- name: Check for clean repo
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "there are changes";
|
||||
git status --porcelain
|
||||
exit 1
|
||||
else
|
||||
echo "no changes in working directory";
|
||||
fi
|
||||
|
2
.github/workflows/nightly-build.yml
vendored
2
.github/workflows/nightly-build.yml
vendored
@ -119,7 +119,7 @@ jobs:
|
||||
os: ubuntu-20.04
|
||||
target_rustflags: ''
|
||||
- target: riscv64gc-unknown-linux-gnu
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
target_rustflags: ''
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
8
.github/workflows/release-pkg.nu
vendored
8
.github/workflows/release-pkg.nu
vendored
@ -82,8 +82,8 @@ print $'Start building ($bin)...'; hr-line
|
||||
# ----------------------------------------------------------------------------
|
||||
# Build for Ubuntu and macOS
|
||||
# ----------------------------------------------------------------------------
|
||||
if $os in [$USE_UBUNTU, 'macos-latest'] {
|
||||
if $os == $USE_UBUNTU {
|
||||
if $os in [$USE_UBUNTU, 'macos-latest', 'ubuntu-latest'] {
|
||||
if $os starts-with ubuntu {
|
||||
sudo apt update
|
||||
sudo apt-get install libxcb-composite0-dev -y
|
||||
}
|
||||
@ -106,7 +106,7 @@ if $os in [$USE_UBUNTU, 'macos-latest'] {
|
||||
_ => {
|
||||
# musl-tools to fix 'Failed to find tool. Is `musl-gcc` installed?'
|
||||
# Actually just for x86_64-unknown-linux-musl target
|
||||
if $os == $USE_UBUNTU { sudo apt install musl-tools -y }
|
||||
if $os starts-with ubuntu { sudo apt install musl-tools -y }
|
||||
cargo-build-nu $flags
|
||||
}
|
||||
}
|
||||
@ -153,7 +153,7 @@ if ($ver | str trim | is-empty) {
|
||||
# Create a release archive and send it to output for the following steps
|
||||
# ----------------------------------------------------------------------------
|
||||
cd $dist; print $'(char nl)Creating release archive...'; hr-line
|
||||
if $os in [$USE_UBUNTU, 'macos-latest'] {
|
||||
if $os in [$USE_UBUNTU, 'macos-latest', 'ubuntu-latest'] {
|
||||
|
||||
let files = (ls | get name)
|
||||
let dest = if $env.RELEASE_TYPE == 'full' { $'($bin)-($version)-($FULL_NAME)' } else { $'($bin)-($version)-($target)' }
|
||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -66,7 +66,7 @@ jobs:
|
||||
os: ubuntu-20.04
|
||||
target_rustflags: ''
|
||||
- target: riscv64gc-unknown-linux-gnu
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
target_rustflags: ''
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
2
.github/workflows/typos.yml
vendored
2
.github/workflows/typos.yml
vendored
@ -10,6 +10,6 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check spelling
|
||||
uses: crate-ci/typos@v1.16.23
|
||||
uses: crate-ci/typos@v1.17.0
|
||||
with:
|
||||
config: ./.github/.typos.toml
|
||||
|
377
Cargo.lock
generated
377
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
55
Cargo.toml
55
Cargo.toml
@ -11,7 +11,7 @@ license = "MIT"
|
||||
name = "nu"
|
||||
repository = "https://github.com/nushell/nushell"
|
||||
rust-version = "1.72.1"
|
||||
version = "0.88.1"
|
||||
version = "0.88.2"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@ -33,7 +33,11 @@ members = [
|
||||
"crates/nu-cmd-lang",
|
||||
"crates/nu-cmd-dataframe",
|
||||
"crates/nu-command",
|
||||
"crates/nu-color-config",
|
||||
"crates/nu-explore",
|
||||
"crates/nu-json",
|
||||
"crates/nu-lsp",
|
||||
"crates/nu-pretty-hex",
|
||||
"crates/nu-protocol",
|
||||
"crates/nu-plugin",
|
||||
"crates/nu_plugin_inc",
|
||||
@ -43,31 +47,34 @@ members = [
|
||||
"crates/nu_plugin_custom_values",
|
||||
"crates/nu_plugin_formats",
|
||||
"crates/nu-std",
|
||||
"crates/nu-table",
|
||||
"crates/nu-term-grid",
|
||||
"crates/nu-utils",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
nu-cli = { path = "./crates/nu-cli", version = "0.88.1" }
|
||||
nu-color-config = { path = "./crates/nu-color-config", version = "0.88.1" }
|
||||
nu-cmd-base = { path = "./crates/nu-cmd-base", version = "0.88.1" }
|
||||
nu-cmd-lang = { path = "./crates/nu-cmd-lang", version = "0.88.1" }
|
||||
nu-cmd-dataframe = { path = "./crates/nu-cmd-dataframe", version = "0.88.1", features = ["dataframe"], optional = true }
|
||||
nu-cmd-extra = { path = "./crates/nu-cmd-extra", version = "0.88.1", optional = true }
|
||||
nu-command = { path = "./crates/nu-command", version = "0.88.1" }
|
||||
nu-engine = { path = "./crates/nu-engine", version = "0.88.1" }
|
||||
nu-explore = { path = "./crates/nu-explore", version = "0.88.1" }
|
||||
nu-json = { path = "./crates/nu-json", version = "0.88.1" }
|
||||
nu-lsp = { path = "./crates/nu-lsp/", version = "0.88.1" }
|
||||
nu-parser = { path = "./crates/nu-parser", version = "0.88.1" }
|
||||
nu-path = { path = "./crates/nu-path", version = "0.88.1" }
|
||||
nu-plugin = { path = "./crates/nu-plugin", optional = true, version = "0.88.1" }
|
||||
nu-pretty-hex = { path = "./crates/nu-pretty-hex", version = "0.88.1" }
|
||||
nu-protocol = { path = "./crates/nu-protocol", version = "0.88.1" }
|
||||
nu-system = { path = "./crates/nu-system", version = "0.88.1" }
|
||||
nu-table = { path = "./crates/nu-table", version = "0.88.1" }
|
||||
nu-term-grid = { path = "./crates/nu-term-grid", version = "0.88.1" }
|
||||
nu-std = { path = "./crates/nu-std", version = "0.88.1" }
|
||||
nu-utils = { path = "./crates/nu-utils", version = "0.88.1" }
|
||||
nu-cli = { path = "./crates/nu-cli", version = "0.88.2" }
|
||||
nu-color-config = { path = "./crates/nu-color-config", version = "0.88.2" }
|
||||
nu-cmd-base = { path = "./crates/nu-cmd-base", version = "0.88.2" }
|
||||
nu-cmd-lang = { path = "./crates/nu-cmd-lang", version = "0.88.2" }
|
||||
nu-cmd-dataframe = { path = "./crates/nu-cmd-dataframe", version = "0.88.2", features = ["dataframe"], optional = true }
|
||||
nu-cmd-extra = { path = "./crates/nu-cmd-extra", version = "0.88.2", optional = true }
|
||||
nu-command = { path = "./crates/nu-command", version = "0.88.2" }
|
||||
nu-engine = { path = "./crates/nu-engine", version = "0.88.2" }
|
||||
nu-explore = { path = "./crates/nu-explore", version = "0.88.2" }
|
||||
nu-json = { path = "./crates/nu-json", version = "0.88.2" }
|
||||
nu-lsp = { path = "./crates/nu-lsp/", version = "0.88.2" }
|
||||
nu-parser = { path = "./crates/nu-parser", version = "0.88.2" }
|
||||
nu-path = { path = "./crates/nu-path", version = "0.88.2" }
|
||||
nu-plugin = { path = "./crates/nu-plugin", optional = true, version = "0.88.2" }
|
||||
nu-pretty-hex = { path = "./crates/nu-pretty-hex", version = "0.88.2" }
|
||||
nu-protocol = { path = "./crates/nu-protocol", version = "0.88.2" }
|
||||
nu-system = { path = "./crates/nu-system", version = "0.88.2" }
|
||||
nu-table = { path = "./crates/nu-table", version = "0.88.2" }
|
||||
nu-term-grid = { path = "./crates/nu-term-grid", version = "0.88.2" }
|
||||
nu-std = { path = "./crates/nu-std", version = "0.88.2" }
|
||||
nu-utils = { path = "./crates/nu-utils", version = "0.88.2" }
|
||||
|
||||
nu-ansi-term = "0.49.0"
|
||||
reedline = { version = "0.27.0", features = ["bashisms", "sqlite"] }
|
||||
|
||||
@ -97,7 +104,7 @@ nix = { version = "0.27", default-features = false, features = [
|
||||
] }
|
||||
|
||||
[dev-dependencies]
|
||||
nu-test-support = { path = "./crates/nu-test-support", version = "0.88.1" }
|
||||
nu-test-support = { path = "./crates/nu-test-support", version = "0.88.2" }
|
||||
assert_cmd = "2.0"
|
||||
criterion = "0.5"
|
||||
pretty_assertions = "1.4"
|
||||
@ -166,7 +173,7 @@ bench = false
|
||||
# To use a development version of a dependency please use a global override here
|
||||
# changing versions in each sub-crate of the workspace is tedious
|
||||
[patch.crates-io]
|
||||
# reedline = { git = "https://github.com/nushell/reedline.git", branch = "main" }
|
||||
reedline = { git = "https://github.com/nushell/reedline.git", branch = "main" }
|
||||
# nu-ansi-term = {git = "https://github.com/nushell/nu-ansi-term.git", branch = "main"}
|
||||
# uu_cp = { git = "https://github.com/uutils/coreutils.git", branch = "main" }
|
||||
|
||||
|
@ -24,13 +24,9 @@ fn canonicalize_path(engine_state: &EngineState, path: &Path) -> PathBuf {
|
||||
}
|
||||
|
||||
fn get_home_path(engine_state: &EngineState) -> PathBuf {
|
||||
let home_path = if let Some(path) = nu_path::home_dir() {
|
||||
let canon_home_path = canonicalize_path(engine_state, &path);
|
||||
canon_home_path
|
||||
} else {
|
||||
std::path::PathBuf::new()
|
||||
};
|
||||
home_path
|
||||
nu_path::home_dir()
|
||||
.map(|path| canonicalize_path(engine_state, &path))
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
// FIXME: All benchmarks live in this 1 file to speed up build times when benchmarking.
|
||||
|
@ -5,31 +5,31 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cli"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
name = "nu-cli"
|
||||
version = "0.88.1"
|
||||
version = "0.88.2"
|
||||
|
||||
[lib]
|
||||
bench = false
|
||||
|
||||
[dev-dependencies]
|
||||
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.88.1" }
|
||||
nu-command = { path = "../nu-command", version = "0.88.1" }
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.88.1" }
|
||||
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.88.2" }
|
||||
nu-command = { path = "../nu-command", version = "0.88.2" }
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.88.2" }
|
||||
rstest = { version = "0.18.1", default-features = false }
|
||||
|
||||
[dependencies]
|
||||
nu-cmd-base = { path = "../nu-cmd-base", version = "0.88.1" }
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.1" }
|
||||
nu-path = { path = "../nu-path", version = "0.88.1" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.88.1" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.1" }
|
||||
nu-utils = { path = "../nu-utils", version = "0.88.1" }
|
||||
nu-color-config = { path = "../nu-color-config", version = "0.88.1" }
|
||||
nu-cmd-base = { path = "../nu-cmd-base", version = "0.88.2" }
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.2" }
|
||||
nu-path = { path = "../nu-path", version = "0.88.2" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.88.2" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.2" }
|
||||
nu-utils = { path = "../nu-utils", version = "0.88.2" }
|
||||
nu-color-config = { path = "../nu-color-config", version = "0.88.2" }
|
||||
nu-ansi-term = "0.49.0"
|
||||
reedline = { version = "0.27.0", features = ["bashisms", "sqlite"] }
|
||||
|
||||
chrono = { default-features = false, features = ["std"], version = "0.4" }
|
||||
crossterm = "0.27"
|
||||
fancy-regex = "0.11"
|
||||
fancy-regex = "0.12"
|
||||
fuzzy-matcher = "0.3"
|
||||
is_executable = "1.0"
|
||||
log = "0.4"
|
||||
@ -37,7 +37,7 @@ miette = { version = "5.10", features = ["fancy-no-backtrace"] }
|
||||
once_cell = "1.18"
|
||||
percent-encoding = "2"
|
||||
pathdiff = "0.2"
|
||||
sysinfo = "0.29"
|
||||
sysinfo = "0.30"
|
||||
unicode-segmentation = "1.10"
|
||||
uuid = { version = "1.6.0", features = ["v4"] }
|
||||
which = "5.0.0"
|
||||
|
@ -34,7 +34,7 @@ impl Command for History {
|
||||
"Show long listing of entries for sqlite history",
|
||||
Some('l'),
|
||||
)
|
||||
.category(Category::Misc)
|
||||
.category(Category::History)
|
||||
}
|
||||
|
||||
fn run(
|
@ -18,7 +18,7 @@ impl Command for HistorySession {
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("history session")
|
||||
.category(Category::Misc)
|
||||
.category(Category::History)
|
||||
.input_output_types(vec![(Type::Nothing, Type::Int)])
|
||||
}
|
||||
|
5
crates/nu-cli/src/commands/history/mod.rs
Normal file
5
crates/nu-cli/src/commands/history/mod.rs
Normal file
@ -0,0 +1,5 @@
|
||||
mod history_;
|
||||
mod history_session;
|
||||
|
||||
pub use history_::History;
|
||||
pub use history_session::HistorySession;
|
@ -1,15 +1,13 @@
|
||||
mod commandline;
|
||||
mod default_context;
|
||||
mod history;
|
||||
mod history_session;
|
||||
mod keybindings;
|
||||
mod keybindings_default;
|
||||
mod keybindings_list;
|
||||
mod keybindings_listen;
|
||||
|
||||
pub use commandline::Commandline;
|
||||
pub use history::History;
|
||||
pub use history_session::HistorySession;
|
||||
pub use history::{History, HistorySession};
|
||||
pub use keybindings::Keybindings;
|
||||
pub use keybindings_default::KeybindingsDefault;
|
||||
pub use keybindings_list::KeybindingsList;
|
||||
|
@ -250,7 +250,9 @@ impl NuCompleter {
|
||||
working_set.get_span_contents(previous_expr.0).to_vec();
|
||||
|
||||
// Completion for .nu files
|
||||
if prev_expr_str == b"use" || prev_expr_str == b"source-env"
|
||||
if prev_expr_str == b"use"
|
||||
|| prev_expr_str == b"overlay use"
|
||||
|| prev_expr_str == b"source-env"
|
||||
{
|
||||
let mut completer =
|
||||
DotNuCompletion::new(self.engine_state.clone());
|
||||
@ -352,9 +354,7 @@ impl NuCompleter {
|
||||
if let Some(external_result) = self.external_completion(
|
||||
block_id, &spans, offset, new_span,
|
||||
) {
|
||||
if !external_result.is_empty() {
|
||||
return external_result;
|
||||
}
|
||||
return external_result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,10 @@ fn complete_rec(
|
||||
Some(base) if matches(base, &entry_name, options) => {
|
||||
let partial = &partial[1..];
|
||||
if !partial.is_empty() || isdir {
|
||||
completions.extend(complete_rec(partial, &path, options, dir, isdir))
|
||||
completions.extend(complete_rec(partial, &path, options, dir, isdir));
|
||||
if entry_name.eq(base) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
completions.push(path)
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use nu_protocol::{
|
||||
};
|
||||
use reedline::Suggestion;
|
||||
use std::{
|
||||
path::{is_separator, MAIN_SEPARATOR as SEP, MAIN_SEPARATOR_STR},
|
||||
path::{is_separator, Path, MAIN_SEPARATOR as SEP, MAIN_SEPARATOR_STR},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
@ -91,16 +91,21 @@ impl Completer for DotNuCompletion {
|
||||
// and transform them into suggestions
|
||||
let output: Vec<Suggestion> = search_dirs
|
||||
.into_iter()
|
||||
.flat_map(|it| {
|
||||
file_path_completion(span, &partial, &it, options)
|
||||
.flat_map(|search_dir| {
|
||||
let completions = file_path_completion(span, &partial, &search_dir, options);
|
||||
completions
|
||||
.into_iter()
|
||||
.filter(|it| {
|
||||
.filter(move |it| {
|
||||
// Different base dir, so we list the .nu files or folders
|
||||
if !is_current_folder {
|
||||
it.1.ends_with(".nu") || it.1.ends_with(SEP)
|
||||
} else {
|
||||
// Lib dirs, so we filter only the .nu files
|
||||
it.1.ends_with(".nu")
|
||||
// Lib dirs, so we filter only the .nu files or directory modules
|
||||
if it.1.ends_with(SEP) {
|
||||
Path::new(&search_dir).join(&it.1).join("mod.nu").exists()
|
||||
} else {
|
||||
it.1.ends_with(".nu")
|
||||
}
|
||||
}
|
||||
})
|
||||
.map(move |x| Suggestion {
|
||||
|
@ -35,6 +35,10 @@ pub fn evaluate_commands(
|
||||
let mut working_set = StateWorkingSet::new(engine_state);
|
||||
|
||||
let output = parse(&mut working_set, None, commands.item.as_bytes(), false);
|
||||
if let Some(warning) = working_set.parse_warnings.first() {
|
||||
report_error(&working_set, warning);
|
||||
}
|
||||
|
||||
if let Some(err) = working_set.parse_errors.first() {
|
||||
report_error(&working_set, err);
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::prompt_update::{POST_PROMPT_MARKER, PRE_PROMPT_MARKER};
|
||||
#[cfg(windows)]
|
||||
use nu_utils::enable_vt_processing;
|
||||
use reedline::DefaultPrompt;
|
||||
@ -11,6 +12,7 @@ use {
|
||||
/// Nushell prompt definition
|
||||
#[derive(Clone)]
|
||||
pub struct NushellPrompt {
|
||||
shell_integration: bool,
|
||||
left_prompt_string: Option<String>,
|
||||
right_prompt_string: Option<String>,
|
||||
default_prompt_indicator: Option<String>,
|
||||
@ -20,15 +22,10 @@ pub struct NushellPrompt {
|
||||
render_right_prompt_on_last_line: bool,
|
||||
}
|
||||
|
||||
impl Default for NushellPrompt {
|
||||
fn default() -> Self {
|
||||
NushellPrompt::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl NushellPrompt {
|
||||
pub fn new() -> NushellPrompt {
|
||||
pub fn new(shell_integration: bool) -> NushellPrompt {
|
||||
NushellPrompt {
|
||||
shell_integration,
|
||||
left_prompt_string: None,
|
||||
right_prompt_string: None,
|
||||
default_prompt_indicator: None,
|
||||
@ -111,7 +108,11 @@ impl Prompt for NushellPrompt {
|
||||
.to_string()
|
||||
.replace('\n', "\r\n");
|
||||
|
||||
prompt.into()
|
||||
if self.shell_integration {
|
||||
format!("{PRE_PROMPT_MARKER}{prompt}{POST_PROMPT_MARKER}").into()
|
||||
} else {
|
||||
prompt.into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,6 @@ use nu_protocol::{
|
||||
Config, PipelineData, Value,
|
||||
};
|
||||
use reedline::Prompt;
|
||||
use std::borrow::Cow;
|
||||
use std::sync::Arc;
|
||||
|
||||
// Name of environment variable where the prompt could be stored
|
||||
pub(crate) const PROMPT_COMMAND: &str = "PROMPT_COMMAND";
|
||||
@ -28,8 +26,8 @@ pub(crate) const TRANSIENT_PROMPT_MULTILINE_INDICATOR: &str =
|
||||
"TRANSIENT_PROMPT_MULTILINE_INDICATOR";
|
||||
// According to Daniel Imms @Tyriar, we need to do these this way:
|
||||
// <133 A><prompt><133 B><command><133 C><command output>
|
||||
const PRE_PROMPT_MARKER: &str = "\x1b]133;A\x1b\\";
|
||||
const POST_PROMPT_MARKER: &str = "\x1b]133;B\x1b\\";
|
||||
pub(crate) const PRE_PROMPT_MARKER: &str = "\x1b]133;A\x1b\\";
|
||||
pub(crate) const POST_PROMPT_MARKER: &str = "\x1b]133;B\x1b\\";
|
||||
|
||||
fn get_prompt_string(
|
||||
prompt: &str,
|
||||
@ -98,12 +96,12 @@ fn get_prompt_string(
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn update_prompt<'prompt>(
|
||||
pub(crate) fn update_prompt(
|
||||
config: &Config,
|
||||
engine_state: &EngineState,
|
||||
stack: &Stack,
|
||||
nu_prompt: &'prompt mut NushellPrompt,
|
||||
) -> &'prompt dyn Prompt {
|
||||
nu_prompt: &mut NushellPrompt,
|
||||
) {
|
||||
let mut stack = stack.clone();
|
||||
|
||||
let left_prompt_string = get_prompt_string(PROMPT_COMMAND, config, engine_state, &mut stack);
|
||||
@ -146,125 +144,55 @@ pub(crate) fn update_prompt<'prompt>(
|
||||
(prompt_vi_insert_string, prompt_vi_normal_string),
|
||||
config.render_right_prompt_on_last_line,
|
||||
);
|
||||
|
||||
let ret_val = nu_prompt as &dyn Prompt;
|
||||
trace!("update_prompt {}:{}:{}", file!(), line!(), column!());
|
||||
|
||||
ret_val
|
||||
}
|
||||
|
||||
struct TransientPrompt {
|
||||
engine_state: Arc<EngineState>,
|
||||
stack: Stack,
|
||||
}
|
||||
|
||||
/// Try getting `$env.TRANSIENT_PROMPT_<X>`, and get `$env.PROMPT_<X>` if that fails
|
||||
fn get_transient_prompt_string(
|
||||
transient_prompt: &str,
|
||||
prompt: &str,
|
||||
/// Construct the transient prompt based on the normal nu_prompt
|
||||
pub(crate) fn make_transient_prompt(
|
||||
config: &Config,
|
||||
engine_state: &EngineState,
|
||||
stack: &mut Stack,
|
||||
) -> Option<String> {
|
||||
get_prompt_string(transient_prompt, config, engine_state, stack)
|
||||
.or_else(|| get_prompt_string(prompt, config, engine_state, stack))
|
||||
}
|
||||
nu_prompt: &NushellPrompt,
|
||||
) -> Box<dyn Prompt> {
|
||||
let mut nu_prompt = nu_prompt.clone();
|
||||
|
||||
impl Prompt for TransientPrompt {
|
||||
fn render_prompt_left(&self) -> Cow<str> {
|
||||
let mut nu_prompt = NushellPrompt::new();
|
||||
let config = &self.engine_state.get_config().clone();
|
||||
let mut stack = self.stack.clone();
|
||||
nu_prompt.update_prompt_left(get_transient_prompt_string(
|
||||
TRANSIENT_PROMPT_COMMAND,
|
||||
PROMPT_COMMAND,
|
||||
config,
|
||||
&self.engine_state,
|
||||
&mut stack,
|
||||
));
|
||||
nu_prompt.render_prompt_left().to_string().into()
|
||||
if let Some(s) = get_prompt_string(TRANSIENT_PROMPT_COMMAND, config, engine_state, stack) {
|
||||
nu_prompt.update_prompt_left(Some(s))
|
||||
}
|
||||
|
||||
fn render_prompt_right(&self) -> Cow<str> {
|
||||
let mut nu_prompt = NushellPrompt::new();
|
||||
let config = &self.engine_state.get_config().clone();
|
||||
let mut stack = self.stack.clone();
|
||||
nu_prompt.update_prompt_right(
|
||||
get_transient_prompt_string(
|
||||
TRANSIENT_PROMPT_COMMAND_RIGHT,
|
||||
PROMPT_COMMAND_RIGHT,
|
||||
config,
|
||||
&self.engine_state,
|
||||
&mut stack,
|
||||
),
|
||||
config.render_right_prompt_on_last_line,
|
||||
);
|
||||
nu_prompt.render_prompt_right().to_string().into()
|
||||
if let Some(s) = get_prompt_string(TRANSIENT_PROMPT_COMMAND_RIGHT, config, engine_state, stack)
|
||||
{
|
||||
nu_prompt.update_prompt_right(Some(s), config.render_right_prompt_on_last_line)
|
||||
}
|
||||
|
||||
fn render_prompt_indicator(&self, prompt_mode: reedline::PromptEditMode) -> Cow<str> {
|
||||
let mut nu_prompt = NushellPrompt::new();
|
||||
let config = &self.engine_state.get_config().clone();
|
||||
let mut stack = self.stack.clone();
|
||||
nu_prompt.update_prompt_indicator(get_transient_prompt_string(
|
||||
TRANSIENT_PROMPT_INDICATOR,
|
||||
PROMPT_INDICATOR,
|
||||
config,
|
||||
&self.engine_state,
|
||||
&mut stack,
|
||||
));
|
||||
nu_prompt.update_prompt_vi_insert(get_transient_prompt_string(
|
||||
TRANSIENT_PROMPT_INDICATOR_VI_INSERT,
|
||||
PROMPT_INDICATOR_VI_INSERT,
|
||||
config,
|
||||
&self.engine_state,
|
||||
&mut stack,
|
||||
));
|
||||
nu_prompt.update_prompt_vi_normal(get_transient_prompt_string(
|
||||
TRANSIENT_PROMPT_INDICATOR_VI_NORMAL,
|
||||
PROMPT_INDICATOR_VI_NORMAL,
|
||||
config,
|
||||
&self.engine_state,
|
||||
&mut stack,
|
||||
));
|
||||
nu_prompt
|
||||
.render_prompt_indicator(prompt_mode)
|
||||
.to_string()
|
||||
.into()
|
||||
if let Some(s) = get_prompt_string(TRANSIENT_PROMPT_INDICATOR, config, engine_state, stack) {
|
||||
nu_prompt.update_prompt_indicator(Some(s))
|
||||
}
|
||||
|
||||
fn render_prompt_multiline_indicator(&self) -> Cow<str> {
|
||||
let mut nu_prompt = NushellPrompt::new();
|
||||
let config = &self.engine_state.get_config().clone();
|
||||
let mut stack = self.stack.clone();
|
||||
nu_prompt.update_prompt_multiline(get_transient_prompt_string(
|
||||
TRANSIENT_PROMPT_MULTILINE_INDICATOR,
|
||||
PROMPT_MULTILINE_INDICATOR,
|
||||
config,
|
||||
&self.engine_state,
|
||||
&mut stack,
|
||||
));
|
||||
nu_prompt
|
||||
.render_prompt_multiline_indicator()
|
||||
.to_string()
|
||||
.into()
|
||||
}
|
||||
|
||||
fn render_prompt_history_search_indicator(
|
||||
&self,
|
||||
history_search: reedline::PromptHistorySearch,
|
||||
) -> Cow<str> {
|
||||
NushellPrompt::new()
|
||||
.render_prompt_history_search_indicator(history_search)
|
||||
.to_string()
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
/// Construct the transient prompt
|
||||
pub(crate) fn transient_prompt(engine_state: Arc<EngineState>, stack: &Stack) -> Box<dyn Prompt> {
|
||||
Box::new(TransientPrompt {
|
||||
if let Some(s) = get_prompt_string(
|
||||
TRANSIENT_PROMPT_INDICATOR_VI_INSERT,
|
||||
config,
|
||||
engine_state,
|
||||
stack: stack.clone(),
|
||||
})
|
||||
stack,
|
||||
) {
|
||||
nu_prompt.update_prompt_vi_insert(Some(s))
|
||||
}
|
||||
if let Some(s) = get_prompt_string(
|
||||
TRANSIENT_PROMPT_INDICATOR_VI_NORMAL,
|
||||
config,
|
||||
engine_state,
|
||||
stack,
|
||||
) {
|
||||
nu_prompt.update_prompt_vi_normal(Some(s))
|
||||
}
|
||||
|
||||
if let Some(s) = get_prompt_string(
|
||||
TRANSIENT_PROMPT_MULTILINE_INDICATOR,
|
||||
config,
|
||||
engine_state,
|
||||
stack,
|
||||
) {
|
||||
nu_prompt.update_prompt_multiline(Some(s))
|
||||
}
|
||||
|
||||
Box::new(nu_prompt)
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ use std::{
|
||||
sync::atomic::Ordering,
|
||||
time::Instant,
|
||||
};
|
||||
use sysinfo::SystemExt;
|
||||
use sysinfo::System;
|
||||
|
||||
// According to Daniel Imms @Tyriar, we need to do these this way:
|
||||
// <133 A><prompt><133 B><command><133 C><command output>
|
||||
@ -54,7 +54,8 @@ pub fn evaluate_repl(
|
||||
) -> Result<()> {
|
||||
use nu_cmd_base::hook;
|
||||
use reedline::Signal;
|
||||
let use_color = engine_state.get_config().use_ansi_coloring;
|
||||
let config = engine_state.get_config();
|
||||
let use_color = config.use_ansi_coloring;
|
||||
|
||||
// Guard against invocation without a connected terminal.
|
||||
// reedline / crossterm event polling will fail without a connected tty
|
||||
@ -68,7 +69,7 @@ pub fn evaluate_repl(
|
||||
|
||||
let mut entry_num = 0;
|
||||
|
||||
let mut nu_prompt = NushellPrompt::new();
|
||||
let mut nu_prompt = NushellPrompt::new(config.shell_integration);
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
// Translate environment variables from Strings to Values
|
||||
@ -134,17 +135,6 @@ pub fn evaluate_repl(
|
||||
use_color,
|
||||
);
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
let sys = sysinfo::System::new();
|
||||
perf(
|
||||
"get sysinfo",
|
||||
start_time,
|
||||
file!(),
|
||||
line!(),
|
||||
column!(),
|
||||
use_color,
|
||||
);
|
||||
|
||||
if let Some(s) = prerun_command {
|
||||
eval_source(
|
||||
engine_state,
|
||||
@ -212,20 +202,6 @@ pub fn evaluate_repl(
|
||||
use_color,
|
||||
);
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
// Reset the SIGQUIT handler
|
||||
if let Some(sig_quit) = engine_state.get_sig_quit() {
|
||||
sig_quit.store(false, Ordering::SeqCst);
|
||||
}
|
||||
perf(
|
||||
"reset sig_quit",
|
||||
start_time,
|
||||
file!(),
|
||||
line!(),
|
||||
column!(),
|
||||
use_color,
|
||||
);
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
let config = engine_state.get_config();
|
||||
|
||||
@ -267,11 +243,7 @@ pub fn evaluate_repl(
|
||||
.with_quick_completions(config.quick_completions)
|
||||
.with_partial_completions(config.partial_completions)
|
||||
.with_ansi_colors(config.use_ansi_coloring)
|
||||
.with_cursor_config(cursor_config)
|
||||
.with_transient_prompt(prompt_update::transient_prompt(
|
||||
engine_reference.clone(),
|
||||
stack,
|
||||
));
|
||||
.with_cursor_config(cursor_config);
|
||||
perf(
|
||||
"reedline builder",
|
||||
start_time,
|
||||
@ -424,7 +396,9 @@ pub fn evaluate_repl(
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
let config = &engine_state.get_config().clone();
|
||||
let prompt = prompt_update::update_prompt(config, engine_state, stack, &mut nu_prompt);
|
||||
prompt_update::update_prompt(config, engine_state, stack, &mut nu_prompt);
|
||||
let transient_prompt =
|
||||
prompt_update::make_transient_prompt(config, engine_state, stack, &nu_prompt);
|
||||
perf(
|
||||
"update_prompt",
|
||||
start_time,
|
||||
@ -437,12 +411,13 @@ pub fn evaluate_repl(
|
||||
entry_num += 1;
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
let input = line_editor.read_line(prompt);
|
||||
line_editor = line_editor.with_transient_prompt(transient_prompt);
|
||||
let input = line_editor.read_line(&nu_prompt);
|
||||
let shell_integration = config.shell_integration;
|
||||
|
||||
match input {
|
||||
Ok(Signal::Success(s)) => {
|
||||
let hostname = sys.host_name();
|
||||
let hostname = System::host_name();
|
||||
let history_supports_meta =
|
||||
matches!(config.history_file_format, HistoryFileFormat::Sqlite);
|
||||
if history_supports_meta && !s.is_empty() && line_editor.has_last_command_context()
|
||||
@ -764,7 +739,7 @@ fn map_nucursorshape_to_cursorshape(shape: NuCursorShape) -> Option<SetCursorSty
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_command_finished_marker(stack: &Stack, engine_state: &EngineState) -> String {
|
||||
fn get_command_finished_marker(stack: &Stack, engine_state: &EngineState) -> String {
|
||||
let exit_code = stack
|
||||
.get_env_var(engine_state, "LAST_EXIT_CODE")
|
||||
.and_then(|e| e.as_i64().ok());
|
||||
|
@ -329,7 +329,6 @@ fn find_matching_block_end_in_expr(
|
||||
Expr::ImportPattern(_) => None,
|
||||
Expr::Overlay(_) => None,
|
||||
Expr::Signature(_) => None,
|
||||
Expr::MatchPattern(_) => None,
|
||||
Expr::MatchBlock(_) => None,
|
||||
Expr::Nothing => None,
|
||||
Expr::Garbage => None,
|
||||
@ -386,6 +385,7 @@ fn find_matching_block_end_in_expr(
|
||||
Argument::Named((_, _, opt_expr)) => opt_expr.as_ref(),
|
||||
Argument::Positional(inner_expr) => Some(inner_expr),
|
||||
Argument::Unknown(inner_expr) => Some(inner_expr),
|
||||
Argument::Spread(inner_expr) => Some(inner_expr),
|
||||
};
|
||||
|
||||
if let Some(inner_expr) = opt_expr {
|
||||
|
@ -220,6 +220,10 @@ pub fn eval_source(
|
||||
source,
|
||||
false,
|
||||
);
|
||||
if let Some(warning) = working_set.parse_warnings.first() {
|
||||
report_error(&working_set, warning);
|
||||
}
|
||||
|
||||
if let Some(err) = working_set.parse_errors.first() {
|
||||
set_last_exit_code(stack, 1);
|
||||
report_error(&working_set, err);
|
||||
|
@ -91,7 +91,7 @@ fn variables_dollar_sign_with_varialblecompletion() {
|
||||
let target_dir = "$ ";
|
||||
let suggestions = completer.complete(target_dir, target_dir.len());
|
||||
|
||||
assert_eq!(7, suggestions.len());
|
||||
assert_eq!(8, suggestions.len());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@ -144,15 +144,34 @@ fn dotnu_completions() {
|
||||
let completion_str = "source-env ".to_string();
|
||||
let suggestions = completer.complete(&completion_str, completion_str.len());
|
||||
|
||||
assert_eq!(1, suggestions.len());
|
||||
assert_eq!(2, suggestions.len());
|
||||
assert_eq!("custom_completion.nu", suggestions.first().unwrap().value);
|
||||
#[cfg(windows)]
|
||||
assert_eq!("directory_completion\\", suggestions.get(1).unwrap().value);
|
||||
#[cfg(not(windows))]
|
||||
assert_eq!("directory_completion/", suggestions.get(1).unwrap().value);
|
||||
|
||||
// Test use completion
|
||||
let completion_str = "use ".to_string();
|
||||
let suggestions = completer.complete(&completion_str, completion_str.len());
|
||||
|
||||
assert_eq!(1, suggestions.len());
|
||||
assert_eq!(2, suggestions.len());
|
||||
assert_eq!("custom_completion.nu", suggestions.first().unwrap().value);
|
||||
#[cfg(windows)]
|
||||
assert_eq!("directory_completion\\", suggestions.get(1).unwrap().value);
|
||||
#[cfg(not(windows))]
|
||||
assert_eq!("directory_completion/", suggestions.get(1).unwrap().value);
|
||||
|
||||
// Test overlay use completion
|
||||
let completion_str = "overlay use ".to_string();
|
||||
let suggestions = completer.complete(&completion_str, completion_str.len());
|
||||
|
||||
assert_eq!(2, suggestions.len());
|
||||
assert_eq!("custom_completion.nu", suggestions.first().unwrap().value);
|
||||
#[cfg(windows)]
|
||||
assert_eq!("directory_completion\\", suggestions.get(1).unwrap().value);
|
||||
#[cfg(not(windows))]
|
||||
assert_eq!("directory_completion/", suggestions.get(1).unwrap().value);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -208,6 +227,7 @@ fn file_completions() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
folder(dir.join("another")),
|
||||
file(dir.join("custom_completion.nu")),
|
||||
folder(dir.join("directory_completion")),
|
||||
file(dir.join("nushell")),
|
||||
folder(dir.join("test_a")),
|
||||
folder(dir.join("test_b")),
|
||||
@ -323,6 +343,7 @@ fn command_ls_with_filecompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another\\".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion\\".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a\\".to_string(),
|
||||
"test_b\\".to_string(),
|
||||
@ -333,6 +354,7 @@ fn command_ls_with_filecompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another/".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion/".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a/".to_string(),
|
||||
"test_b/".to_string(),
|
||||
@ -355,6 +377,7 @@ fn command_open_with_filecompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another\\".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion\\".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a\\".to_string(),
|
||||
"test_b\\".to_string(),
|
||||
@ -365,6 +388,7 @@ fn command_open_with_filecompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another/".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion/".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a/".to_string(),
|
||||
"test_b/".to_string(),
|
||||
@ -388,6 +412,7 @@ fn command_rm_with_globcompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another\\".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion\\".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a\\".to_string(),
|
||||
"test_b\\".to_string(),
|
||||
@ -398,6 +423,7 @@ fn command_rm_with_globcompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another/".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion/".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a/".to_string(),
|
||||
"test_b/".to_string(),
|
||||
@ -421,6 +447,7 @@ fn command_cp_with_globcompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another\\".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion\\".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a\\".to_string(),
|
||||
"test_b\\".to_string(),
|
||||
@ -431,6 +458,7 @@ fn command_cp_with_globcompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another/".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion/".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a/".to_string(),
|
||||
"test_b/".to_string(),
|
||||
@ -454,6 +482,7 @@ fn command_save_with_filecompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another\\".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion\\".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a\\".to_string(),
|
||||
"test_b\\".to_string(),
|
||||
@ -464,6 +493,7 @@ fn command_save_with_filecompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another/".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion/".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a/".to_string(),
|
||||
"test_b/".to_string(),
|
||||
@ -487,6 +517,7 @@ fn command_touch_with_filecompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another\\".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion\\".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a\\".to_string(),
|
||||
"test_b\\".to_string(),
|
||||
@ -497,6 +528,7 @@ fn command_touch_with_filecompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another/".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion/".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a/".to_string(),
|
||||
"test_b/".to_string(),
|
||||
@ -520,6 +552,7 @@ fn command_watch_with_filecompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another\\".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion\\".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a\\".to_string(),
|
||||
"test_b\\".to_string(),
|
||||
@ -530,6 +563,7 @@ fn command_watch_with_filecompletion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another/".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion/".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a/".to_string(),
|
||||
"test_b/".to_string(),
|
||||
@ -625,6 +659,7 @@ fn folder_with_directorycompletions() {
|
||||
// Create the expected values
|
||||
let expected_paths: Vec<String> = vec![
|
||||
folder(dir.join("another")),
|
||||
folder(dir.join("directory_completion")),
|
||||
folder(dir.join("test_a")),
|
||||
folder(dir.join("test_b")),
|
||||
folder(dir.join(".hidden_folder")),
|
||||
@ -839,6 +874,7 @@ fn unknown_command_completion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another\\".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion\\".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a\\".to_string(),
|
||||
"test_b\\".to_string(),
|
||||
@ -849,6 +885,7 @@ fn unknown_command_completion() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another/".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion/".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a/".to_string(),
|
||||
"test_b/".to_string(),
|
||||
@ -899,6 +936,7 @@ fn filecompletions_triggers_after_cursor() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another\\".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion\\".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a\\".to_string(),
|
||||
"test_b\\".to_string(),
|
||||
@ -909,6 +947,7 @@ fn filecompletions_triggers_after_cursor() {
|
||||
let expected_paths: Vec<String> = vec![
|
||||
"another/".to_string(),
|
||||
"custom_completion.nu".to_string(),
|
||||
"directory_completion/".to_string(),
|
||||
"nushell".to_string(),
|
||||
"test_a/".to_string(),
|
||||
"test_b/".to_string(),
|
||||
|
@ -5,21 +5,21 @@ edition = "2021"
|
||||
license = "MIT"
|
||||
name = "nu-cmd-base"
|
||||
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-base"
|
||||
version = "0.88.1"
|
||||
version = "0.88.2"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.1" }
|
||||
nu-glob = { path = "../nu-glob", version = "0.88.1" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.88.1" }
|
||||
nu-path = { path = "../nu-path", version = "0.88.1" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.1" }
|
||||
nu-utils = { path = "../nu-utils", version = "0.88.1" }
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.2" }
|
||||
nu-glob = { path = "../nu-glob", version = "0.88.2" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.88.2" }
|
||||
nu-path = { path = "../nu-path", version = "0.88.2" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.2" }
|
||||
nu-utils = { path = "../nu-utils", version = "0.88.2" }
|
||||
|
||||
indexmap = "2.1"
|
||||
miette = "5.10.0"
|
||||
|
||||
[dev-dependencies]
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.88.1" }
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.88.2" }
|
||||
rstest = "0.18.2"
|
||||
|
@ -5,7 +5,7 @@ edition = "2021"
|
||||
license = "MIT"
|
||||
name = "nu-cmd-dataframe"
|
||||
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-dataframe"
|
||||
version = "0.88.1"
|
||||
version = "0.88.2"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@ -13,9 +13,9 @@ version = "0.88.1"
|
||||
bench = false
|
||||
|
||||
[dependencies]
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.1" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.88.1" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.1" }
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.2" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.88.2" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.2" }
|
||||
|
||||
# Potential dependencies for extras
|
||||
chrono = { version = "0.4", features = ["std", "unstable-locales"], default-features = false }
|
||||
@ -26,9 +26,9 @@ num = { version = "0.4", optional = true }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
sqlparser = { version = "0.39", optional = true }
|
||||
polars-io = { version = "0.35", features = ["avro"], optional = true }
|
||||
polars-arrow = "0.35"
|
||||
polars-ops = "0.35"
|
||||
polars-plan = "0.35"
|
||||
polars-arrow = { version = "0.35", optional = true }
|
||||
polars-ops = { version = "0.35", optional = true }
|
||||
polars-plan = { version = "0.35", optional = true }
|
||||
|
||||
[dependencies.polars]
|
||||
features = [
|
||||
@ -65,9 +65,9 @@ optional = true
|
||||
version = "0.35"
|
||||
|
||||
[features]
|
||||
dataframe = ["num", "polars", "polars-io", "sqlparser"]
|
||||
dataframe = ["num", "polars", "polars-io", "polars-arrow", "polars-ops", "polars-plan", "sqlparser"]
|
||||
default = []
|
||||
|
||||
[dev-dependencies]
|
||||
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.88.1" }
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.88.1" }
|
||||
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.88.2" }
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.88.2" }
|
||||
|
@ -1,11 +1,12 @@
|
||||
use super::{DataFrameValue, NuDataFrame};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
use chrono::{DateTime, FixedOffset, NaiveDateTime};
|
||||
use chrono::{DateTime, Duration, FixedOffset, NaiveTime, TimeZone, Utc};
|
||||
use chrono_tz::Tz;
|
||||
use indexmap::map::{Entry, IndexMap};
|
||||
use nu_protocol::{Record, ShellError, Span, Value};
|
||||
use polars::chunked_array::builder::AnonymousOwnedListBuilder;
|
||||
use polars::chunked_array::object::builder::ObjectChunkedBuilder;
|
||||
use polars::chunked_array::ChunkedArray;
|
||||
use polars::datatypes::AnyValue;
|
||||
use polars::export::arrow::Either;
|
||||
use polars::prelude::{
|
||||
DataFrame, DataType, DatetimeChunked, Float64Type, Int64Type, IntoSeries,
|
||||
@ -13,11 +14,14 @@ use polars::prelude::{
|
||||
ListUtf8ChunkedBuilder, NamedFrom, NewChunkedArray, ObjectType, Series, TemporalMethods,
|
||||
TimeUnit,
|
||||
};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
const SECS_PER_DAY: i64 = 86_400;
|
||||
use nu_protocol::{Record, ShellError, Span, Value};
|
||||
|
||||
// The values capacity is for the size of an internal vec.
|
||||
use super::{DataFrameValue, NuDataFrame};
|
||||
|
||||
const NANOS_PER_DAY: i64 = 86_400_000_000_000;
|
||||
|
||||
// The values capacity is for the size of an vec.
|
||||
// Since this is impossible to determine without traversing every value
|
||||
// I just picked one. Since this is for converting back and forth
|
||||
// between nushell tables the values shouldn't be too extremely large for
|
||||
@ -199,7 +203,7 @@ fn value_to_input_type(value: &Value) -> InputType {
|
||||
Value::Filesize { .. } => InputType::Filesize,
|
||||
Value::List { vals, .. } => {
|
||||
// We need to determined the type inside of the list.
|
||||
// Since Value::List does not have any kind of internal
|
||||
// Since Value::List does not have any kind of
|
||||
// type information, we need to look inside the list.
|
||||
// This will cause errors if lists have inconsistent types.
|
||||
// Basically, if a list column needs to be converted to dataframe,
|
||||
@ -775,28 +779,21 @@ fn series_to_values(
|
||||
}),
|
||||
Some(ca) => {
|
||||
let it = ca.into_iter();
|
||||
let values: Vec<Value> =
|
||||
if let (Some(size), Some(from_row)) = (maybe_size, maybe_from_row) {
|
||||
Either::Left(it.skip(from_row).take(size))
|
||||
if let (Some(size), Some(from_row)) = (maybe_size, maybe_from_row) {
|
||||
Either::Left(it.skip(from_row).take(size))
|
||||
} else {
|
||||
Either::Right(it)
|
||||
}
|
||||
.map(|ca| {
|
||||
let sublist: Vec<Value> = if let Some(ref s) = ca {
|
||||
series_to_values(s, None, None, Span::unknown())?
|
||||
} else {
|
||||
Either::Right(it)
|
||||
}
|
||||
.map(|ca| {
|
||||
let sublist = ca
|
||||
.map(|ref s| {
|
||||
match series_to_values(s, None, None, Span::unknown()) {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
eprintln!("Error list values: {e}");
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
})
|
||||
.unwrap_or(vec![]);
|
||||
Value::list(sublist, span)
|
||||
})
|
||||
.collect::<Vec<Value>>();
|
||||
Ok(values)
|
||||
// empty item
|
||||
vec![]
|
||||
};
|
||||
Ok(Value::list(sublist, span))
|
||||
})
|
||||
.collect::<Result<Vec<Value>, ShellError>>()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -817,51 +814,16 @@ fn series_to_values(
|
||||
}
|
||||
.map(|v| match v {
|
||||
Some(a) => {
|
||||
// elapsed time in day since 1970-01-01
|
||||
let seconds = a as i64 * SECS_PER_DAY;
|
||||
let naive_datetime = match NaiveDateTime::from_timestamp_opt(seconds, 0) {
|
||||
Some(val) => val,
|
||||
None => {
|
||||
return Value::error(
|
||||
ShellError::UnsupportedInput {
|
||||
msg: "The given local datetime representation is invalid."
|
||||
.to_string(),
|
||||
input: format!("timestamp is {a:?}"),
|
||||
msg_span: span,
|
||||
input_span: Span::unknown(),
|
||||
},
|
||||
span,
|
||||
)
|
||||
}
|
||||
};
|
||||
// Zero length offset
|
||||
let offset = match FixedOffset::east_opt(0) {
|
||||
Some(val) => val,
|
||||
None => {
|
||||
return Value::error(
|
||||
ShellError::UnsupportedInput {
|
||||
msg: "The given local datetime representation is invalid."
|
||||
.to_string(),
|
||||
input: format!("timestamp is {a:?}"),
|
||||
msg_span: span,
|
||||
input_span: Span::unknown(),
|
||||
},
|
||||
span,
|
||||
)
|
||||
}
|
||||
};
|
||||
let datetime =
|
||||
DateTime::<FixedOffset>::from_naive_utc_and_offset(naive_datetime, offset);
|
||||
|
||||
Value::date(datetime, span)
|
||||
let nanos = nanos_per_day(a);
|
||||
let datetime = datetime_from_epoch_nanos(nanos, &None, span)?;
|
||||
Ok(Value::date(datetime, span))
|
||||
}
|
||||
None => Value::nothing(span),
|
||||
None => Ok(Value::nothing(span)),
|
||||
})
|
||||
.collect::<Vec<Value>>();
|
||||
|
||||
.collect::<Result<Vec<Value>, ShellError>>()?;
|
||||
Ok(values)
|
||||
}
|
||||
DataType::Datetime(time_unit, _) => {
|
||||
DataType::Datetime(time_unit, tz) => {
|
||||
let casted = series.datetime().map_err(|e| ShellError::GenericError {
|
||||
error: "Error casting column to datetime".into(),
|
||||
msg: "".into(),
|
||||
@ -878,55 +840,46 @@ fn series_to_values(
|
||||
}
|
||||
.map(|v| match v {
|
||||
Some(a) => {
|
||||
let unit_divisor = match time_unit {
|
||||
TimeUnit::Nanoseconds => 1_000_000_000,
|
||||
TimeUnit::Microseconds => 1_000_000,
|
||||
TimeUnit::Milliseconds => 1_000,
|
||||
};
|
||||
// elapsed time in nano/micro/milliseconds since 1970-01-01
|
||||
let seconds = a / unit_divisor;
|
||||
let naive_datetime = match NaiveDateTime::from_timestamp_opt(seconds, 0) {
|
||||
Some(val) => val,
|
||||
None => {
|
||||
return Value::error(
|
||||
ShellError::UnsupportedInput {
|
||||
msg: "The given local datetime representation is invalid."
|
||||
.to_string(),
|
||||
input: format!("timestamp is {a:?}"),
|
||||
msg_span: span,
|
||||
input_span: Span::unknown(),
|
||||
},
|
||||
span,
|
||||
)
|
||||
}
|
||||
};
|
||||
// Zero length offset
|
||||
let offset = match FixedOffset::east_opt(0) {
|
||||
Some(val) => val,
|
||||
None => {
|
||||
return Value::error(
|
||||
ShellError::UnsupportedInput {
|
||||
msg: "The given local datetime representation is invalid."
|
||||
.to_string(),
|
||||
input: format!("timestamp is {a:?}"),
|
||||
msg_span: span,
|
||||
input_span: Span::unknown(),
|
||||
},
|
||||
span,
|
||||
)
|
||||
}
|
||||
};
|
||||
let datetime =
|
||||
DateTime::<FixedOffset>::from_naive_utc_and_offset(naive_datetime, offset);
|
||||
|
||||
Value::date(datetime, span)
|
||||
let nanos = nanos_from_timeunit(a, *time_unit);
|
||||
let datetime = datetime_from_epoch_nanos(nanos, tz, span)?;
|
||||
Ok(Value::date(datetime, span))
|
||||
}
|
||||
None => Value::nothing(span),
|
||||
None => Ok(Value::nothing(span)),
|
||||
})
|
||||
.collect::<Vec<Value>>();
|
||||
|
||||
.collect::<Result<Vec<Value>, ShellError>>()?;
|
||||
Ok(values)
|
||||
}
|
||||
DataType::Struct(polar_fields) => {
|
||||
let casted = series.struct_().map_err(|e| ShellError::GenericError {
|
||||
error: "Error casting column to struct".into(),
|
||||
msg: "".to_string(),
|
||||
span: None,
|
||||
help: Some(e.to_string()),
|
||||
inner: Vec::new(),
|
||||
})?;
|
||||
let it = casted.into_iter();
|
||||
let values: Result<Vec<Value>, ShellError> =
|
||||
if let (Some(size), Some(from_row)) = (maybe_size, maybe_from_row) {
|
||||
Either::Left(it.skip(from_row).take(size))
|
||||
} else {
|
||||
Either::Right(it)
|
||||
}
|
||||
.map(|any_values| {
|
||||
let vals: Result<Vec<Value>, ShellError> = any_values
|
||||
.iter()
|
||||
.map(|v| any_value_to_value(v, span))
|
||||
.collect();
|
||||
let cols: Vec<String> = polar_fields
|
||||
.iter()
|
||||
.map(|field| field.name.to_string())
|
||||
.collect();
|
||||
let record = Record::from_raw_cols_vals(cols, vals?);
|
||||
Ok(Value::record(record, span))
|
||||
})
|
||||
.collect();
|
||||
values
|
||||
}
|
||||
DataType::Time => {
|
||||
let casted =
|
||||
series
|
||||
@ -963,10 +916,152 @@ fn series_to_values(
|
||||
}
|
||||
}
|
||||
|
||||
fn any_value_to_value(any_value: &AnyValue, span: Span) -> Result<Value, ShellError> {
|
||||
match any_value {
|
||||
AnyValue::Null => Ok(Value::nothing(span)),
|
||||
AnyValue::Boolean(b) => Ok(Value::bool(*b, span)),
|
||||
AnyValue::Utf8(s) => Ok(Value::string(s.to_string(), span)),
|
||||
AnyValue::UInt8(i) => Ok(Value::int(*i as i64, span)),
|
||||
AnyValue::UInt16(i) => Ok(Value::int(*i as i64, span)),
|
||||
AnyValue::UInt32(i) => Ok(Value::int(*i as i64, span)),
|
||||
AnyValue::UInt64(i) => Ok(Value::int(*i as i64, span)),
|
||||
AnyValue::Int8(i) => Ok(Value::int(*i as i64, span)),
|
||||
AnyValue::Int16(i) => Ok(Value::int(*i as i64, span)),
|
||||
AnyValue::Int32(i) => Ok(Value::int(*i as i64, span)),
|
||||
AnyValue::Int64(i) => Ok(Value::int(*i, span)),
|
||||
AnyValue::Float32(f) => Ok(Value::float(*f as f64, span)),
|
||||
AnyValue::Float64(f) => Ok(Value::float(*f, span)),
|
||||
AnyValue::Date(d) => {
|
||||
let nanos = nanos_per_day(*d);
|
||||
datetime_from_epoch_nanos(nanos, &None, span)
|
||||
.map(|datetime| Value::date(datetime, span))
|
||||
}
|
||||
AnyValue::Datetime(a, time_unit, tz) => {
|
||||
let nanos = nanos_from_timeunit(*a, *time_unit);
|
||||
datetime_from_epoch_nanos(nanos, tz, span).map(|datetime| Value::date(datetime, span))
|
||||
}
|
||||
AnyValue::Duration(a, time_unit) => {
|
||||
let nanos = match time_unit {
|
||||
TimeUnit::Nanoseconds => *a,
|
||||
TimeUnit::Microseconds => *a * 1_000,
|
||||
TimeUnit::Milliseconds => *a * 1_000_000,
|
||||
};
|
||||
Ok(Value::duration(nanos, span))
|
||||
}
|
||||
// AnyValue::Time represents the current time since midnight.
|
||||
// Unfortunately, there is no timezone related information.
|
||||
// Given this, calculate the current date from UTC and add the time.
|
||||
AnyValue::Time(nanos) => time_from_midnight(*nanos, span),
|
||||
AnyValue::List(series) => {
|
||||
series_to_values(series, None, None, span).map(|values| Value::list(values, span))
|
||||
}
|
||||
AnyValue::Struct(_idx, _struct_array, _s_fields) => {
|
||||
// This should convert to a StructOwned object.
|
||||
let static_value =
|
||||
any_value
|
||||
.clone()
|
||||
.into_static()
|
||||
.map_err(|e| ShellError::GenericError {
|
||||
error: "Cannot convert polars struct to static value".into(),
|
||||
msg: e.to_string(),
|
||||
span: Some(span),
|
||||
help: None,
|
||||
inner: Vec::new(),
|
||||
})?;
|
||||
any_value_to_value(&static_value, span)
|
||||
}
|
||||
AnyValue::StructOwned(struct_tuple) => {
|
||||
let values: Result<Vec<Value>, ShellError> = struct_tuple
|
||||
.0
|
||||
.iter()
|
||||
.map(|s| any_value_to_value(s, span))
|
||||
.collect();
|
||||
let fields = struct_tuple
|
||||
.1
|
||||
.iter()
|
||||
.map(|f| f.name().to_string())
|
||||
.collect();
|
||||
Ok(Value::Record {
|
||||
val: Record::from_raw_cols_vals(fields, values?),
|
||||
internal_span: span,
|
||||
})
|
||||
}
|
||||
AnyValue::Utf8Owned(s) => Ok(Value::string(s.to_string(), span)),
|
||||
AnyValue::Binary(bytes) => Ok(Value::binary(*bytes, span)),
|
||||
AnyValue::BinaryOwned(bytes) => Ok(Value::binary(bytes.to_owned(), span)),
|
||||
e => Err(ShellError::GenericError {
|
||||
error: "Error creating Value".into(),
|
||||
msg: "".to_string(),
|
||||
span: None,
|
||||
help: Some(format!("Value not supported in nushell: {e}")),
|
||||
inner: Vec::new(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
fn nanos_per_day(days: i32) -> i64 {
|
||||
days as i64 * NANOS_PER_DAY
|
||||
}
|
||||
|
||||
fn nanos_from_timeunit(a: i64, time_unit: TimeUnit) -> i64 {
|
||||
a * match time_unit {
|
||||
TimeUnit::Microseconds => 1_000, // Convert microseconds to nanoseconds
|
||||
TimeUnit::Milliseconds => 1_000_000, // Convert milliseconds to nanoseconds
|
||||
TimeUnit::Nanoseconds => 1, // Already in nanoseconds
|
||||
}
|
||||
}
|
||||
|
||||
fn datetime_from_epoch_nanos(
|
||||
nanos: i64,
|
||||
timezone: &Option<String>,
|
||||
span: Span,
|
||||
) -> Result<DateTime<FixedOffset>, ShellError> {
|
||||
let tz: Tz = if let Some(polars_tz) = timezone {
|
||||
polars_tz
|
||||
.parse::<Tz>()
|
||||
.map_err(|_| ShellError::GenericError {
|
||||
error: format!("Could not parse polars timezone: {polars_tz}"),
|
||||
msg: "".to_string(),
|
||||
span: Some(span),
|
||||
help: None,
|
||||
inner: vec![],
|
||||
})?
|
||||
} else {
|
||||
Tz::UTC
|
||||
};
|
||||
|
||||
Ok(tz.timestamp_nanos(nanos).fixed_offset())
|
||||
}
|
||||
|
||||
fn time_from_midnight(nanos: i64, span: Span) -> Result<Value, ShellError> {
|
||||
let today = Utc::now().date_naive();
|
||||
NaiveTime::from_hms_opt(0, 0, 0) // midnight
|
||||
.map(|time| time + Duration::nanoseconds(nanos)) // current time
|
||||
.map(|time| today.and_time(time)) // current date and time
|
||||
.and_then(|datetime| {
|
||||
FixedOffset::east_opt(0) // utc
|
||||
.map(|offset| {
|
||||
DateTime::<FixedOffset>::from_naive_utc_and_offset(datetime, offset)
|
||||
})
|
||||
})
|
||||
.map(|datetime| Value::date(datetime, span)) // current date and time
|
||||
.ok_or(ShellError::CantConvert {
|
||||
to_type: "datetime".to_string(),
|
||||
from_type: "polars time".to_string(),
|
||||
span,
|
||||
help: Some("Could not convert polars time of {nanos} to datetime".to_string()),
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use indexmap::indexmap;
|
||||
use nu_protocol::record;
|
||||
use polars::export::arrow::array::{BooleanArray, PrimitiveArray};
|
||||
use polars::prelude::Field;
|
||||
use polars_io::prelude::StructArray;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_parsed_column_string_list() -> Result<(), Box<dyn std::error::Error>> {
|
||||
@ -1001,4 +1096,181 @@ mod tests {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_any_value_to_value() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let span = Span::test_data();
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::Null, span)?,
|
||||
Value::nothing(span)
|
||||
);
|
||||
|
||||
let test_bool = true;
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::Boolean(test_bool), span)?,
|
||||
Value::bool(test_bool, span)
|
||||
);
|
||||
|
||||
let test_str = "foo";
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::Utf8(test_str), span)?,
|
||||
Value::string(test_str.to_string(), span)
|
||||
);
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::Utf8Owned(test_str.into()), span)?,
|
||||
Value::string(test_str.to_owned(), span)
|
||||
);
|
||||
|
||||
let tests_uint8 = 4;
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::UInt8(tests_uint8), span)?,
|
||||
Value::int(tests_uint8 as i64, span)
|
||||
);
|
||||
|
||||
let tests_uint16 = 233;
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::UInt16(tests_uint16), span)?,
|
||||
Value::int(tests_uint16 as i64, span)
|
||||
);
|
||||
|
||||
let tests_uint32 = 897688233;
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::UInt32(tests_uint32), span)?,
|
||||
Value::int(tests_uint32 as i64, span)
|
||||
);
|
||||
|
||||
let tests_uint64 = 903225135897388233;
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::UInt64(tests_uint64), span)?,
|
||||
Value::int(tests_uint64 as i64, span)
|
||||
);
|
||||
|
||||
let tests_float32 = 903225135897388233.3223353;
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::Float32(tests_float32), span)?,
|
||||
Value::float(tests_float32 as f64, span)
|
||||
);
|
||||
|
||||
let tests_float64 = 9064251358973882322333.64233533232;
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::Float64(tests_float64), span)?,
|
||||
Value::float(tests_float64, span)
|
||||
);
|
||||
|
||||
let test_days = 10_957;
|
||||
let comparison_date = Utc
|
||||
.with_ymd_and_hms(2000, 1, 1, 0, 0, 0)
|
||||
.unwrap()
|
||||
.fixed_offset();
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::Date(test_days), span)?,
|
||||
Value::date(comparison_date, span)
|
||||
);
|
||||
|
||||
let test_millis = 946_684_800_000;
|
||||
assert_eq!(
|
||||
any_value_to_value(
|
||||
&AnyValue::Datetime(test_millis, TimeUnit::Milliseconds, &None),
|
||||
span
|
||||
)?,
|
||||
Value::date(comparison_date, span)
|
||||
);
|
||||
|
||||
let test_duration_millis = 99_999;
|
||||
let test_duration_micros = 99_999_000;
|
||||
let test_duration_nanos = 99_999_000_000;
|
||||
assert_eq!(
|
||||
any_value_to_value(
|
||||
&AnyValue::Duration(test_duration_nanos, TimeUnit::Nanoseconds),
|
||||
span
|
||||
)?,
|
||||
Value::duration(test_duration_nanos, span)
|
||||
);
|
||||
assert_eq!(
|
||||
any_value_to_value(
|
||||
&AnyValue::Duration(test_duration_micros, TimeUnit::Microseconds),
|
||||
span
|
||||
)?,
|
||||
Value::duration(test_duration_nanos, span)
|
||||
);
|
||||
assert_eq!(
|
||||
any_value_to_value(
|
||||
&AnyValue::Duration(test_duration_millis, TimeUnit::Milliseconds),
|
||||
span
|
||||
)?,
|
||||
Value::duration(test_duration_nanos, span)
|
||||
);
|
||||
|
||||
let test_binary = b"sdf2332f32q3f3afwaf3232f32";
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::Binary(test_binary), span)?,
|
||||
Value::binary(test_binary.to_vec(), span)
|
||||
);
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::BinaryOwned(test_binary.to_vec()), span)?,
|
||||
Value::binary(test_binary.to_vec(), span)
|
||||
);
|
||||
|
||||
let test_time_nanos = 54_000_000_000_000;
|
||||
let test_time = DateTime::<FixedOffset>::from_naive_utc_and_offset(
|
||||
Utc::now()
|
||||
.date_naive()
|
||||
.and_time(NaiveTime::from_hms_opt(15, 00, 00).unwrap()),
|
||||
FixedOffset::east_opt(0).unwrap(),
|
||||
);
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::Time(test_time_nanos), span)?,
|
||||
Value::date(test_time, span)
|
||||
);
|
||||
|
||||
let test_list_series = Series::new("int series", &[1, 2, 3]);
|
||||
let comparison_list_series = Value::list(
|
||||
vec![
|
||||
Value::int(1, span),
|
||||
Value::int(2, span),
|
||||
Value::int(3, span),
|
||||
],
|
||||
span,
|
||||
);
|
||||
assert_eq!(
|
||||
any_value_to_value(&AnyValue::List(test_list_series), span)?,
|
||||
comparison_list_series
|
||||
);
|
||||
|
||||
let field_value_0 = AnyValue::Int32(1);
|
||||
let field_value_1 = AnyValue::Boolean(true);
|
||||
let values = vec![field_value_0, field_value_1];
|
||||
let field_name_0 = "num_field";
|
||||
let field_name_1 = "bool_field";
|
||||
let fields = vec![
|
||||
Field::new(field_name_0, DataType::Int32),
|
||||
Field::new(field_name_1, DataType::Boolean),
|
||||
];
|
||||
let test_owned_struct = AnyValue::StructOwned(Box::new((values, fields.clone())));
|
||||
let comparison_owned_record = Value::test_record(record!(
|
||||
field_name_0 => Value::int(1, span),
|
||||
field_name_1 => Value::bool(true, span),
|
||||
));
|
||||
assert_eq!(
|
||||
any_value_to_value(&test_owned_struct, span)?,
|
||||
comparison_owned_record.clone()
|
||||
);
|
||||
|
||||
let test_int_arr = PrimitiveArray::from([Some(1_i32)]);
|
||||
let test_bool_arr = BooleanArray::from([Some(true)]);
|
||||
let test_struct_arr = StructArray::new(
|
||||
DataType::Struct(fields.clone()).to_arrow(),
|
||||
vec![Box::new(test_int_arr), Box::new(test_bool_arr)],
|
||||
None,
|
||||
);
|
||||
assert_eq!(
|
||||
any_value_to_value(
|
||||
&AnyValue::Struct(0, &test_struct_arr, fields.as_slice()),
|
||||
span
|
||||
)?,
|
||||
comparison_owned_record
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,10 @@ impl NuDataFrame {
|
||||
.map(|i| format!("{i}"))
|
||||
.collect::<Vec<String>>();
|
||||
|
||||
conversion::insert_record(&mut column_values, Record { cols, vals })?
|
||||
conversion::insert_record(
|
||||
&mut column_values,
|
||||
Record::from_raw_cols_vals(cols, vals),
|
||||
)?
|
||||
}
|
||||
Value::Record { val: record, .. } => {
|
||||
conversion::insert_record(&mut column_values, record)?
|
||||
|
@ -5,7 +5,7 @@ edition = "2021"
|
||||
license = "MIT"
|
||||
name = "nu-cmd-extra"
|
||||
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-extra"
|
||||
version = "0.88.1"
|
||||
version = "0.88.2"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@ -13,22 +13,22 @@ version = "0.88.1"
|
||||
bench = false
|
||||
|
||||
[dependencies]
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.1" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.88.1" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.1" }
|
||||
nu-cmd-base = { path = "../nu-cmd-base", version = "0.88.1" }
|
||||
nu-utils = { path = "../nu-utils", version = "0.88.1" }
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.2" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.88.2" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.2" }
|
||||
nu-cmd-base = { path = "../nu-cmd-base", version = "0.88.2" }
|
||||
nu-utils = { path = "../nu-utils", version = "0.88.2" }
|
||||
|
||||
# Potential dependencies for extras
|
||||
heck = "0.4.1"
|
||||
num-traits = "0.2"
|
||||
ahash = "0.8.3"
|
||||
nu-ansi-term = "0.49.0"
|
||||
fancy-regex = "0.11.0"
|
||||
fancy-regex = "0.12.0"
|
||||
rust-embed = "8.0.0"
|
||||
serde = "1.0.164"
|
||||
nu-pretty-hex = { version = "0.88.1", path = "../nu-pretty-hex" }
|
||||
nu-json = { version = "0.88.1", path = "../nu-json" }
|
||||
nu-pretty-hex = { version = "0.88.2", path = "../nu-pretty-hex" }
|
||||
nu-json = { version = "0.88.2", path = "../nu-json" }
|
||||
serde_urlencoded = "0.7.1"
|
||||
htmlescape = "0.3.1"
|
||||
|
||||
@ -37,6 +37,6 @@ extra = ["default"]
|
||||
default = []
|
||||
|
||||
[dev-dependencies]
|
||||
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.88.1" }
|
||||
nu-command = { path = "../nu-command", version = "0.88.1" }
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.88.1" }
|
||||
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.88.2" }
|
||||
nu-command = { path = "../nu-command", version = "0.88.2" }
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.88.2" }
|
||||
|
@ -65,7 +65,7 @@ pub fn add_extra_command_context(mut engine_state: EngineState) -> EngineState {
|
||||
bind_command!(platform::ansi::Gradient);
|
||||
|
||||
bind_command!(
|
||||
strings::format::Format,
|
||||
strings::format::FormatPattern,
|
||||
strings::encode_decode::EncodeHex,
|
||||
strings::encode_decode::DecodeHex,
|
||||
strings::str_::case::Str,
|
||||
|
@ -10,15 +10,15 @@ use nu_protocol::{
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Format;
|
||||
pub struct FormatPattern;
|
||||
|
||||
impl Command for Format {
|
||||
impl Command for FormatPattern {
|
||||
fn name(&self) -> &str {
|
||||
"format"
|
||||
"format pattern"
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("format")
|
||||
Signature::build("format pattern")
|
||||
.input_output_types(vec![
|
||||
(Type::Table(vec![]), Type::List(Box::new(Type::String))),
|
||||
(Type::Record(vec![]), Type::Any),
|
||||
@ -80,12 +80,12 @@ impl Command for Format {
|
||||
vec![
|
||||
Example {
|
||||
description: "Print filenames with their sizes",
|
||||
example: "ls | format '{name}: {size}'",
|
||||
example: "ls | format pattern '{name}: {size}'",
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "Print elements from some columns of a table",
|
||||
example: "[[col1, col2]; [v1, v2] [v3, v4]] | format '{col2}'",
|
||||
example: "[[col1, col2]; [v1, v2] [v3, v4]] | format pattern '{col2}'",
|
||||
result: Some(Value::list(
|
||||
vec![Value::test_string("v2"), Value::test_string("v4")],
|
||||
Span::test_data(),
|
||||
@ -318,8 +318,8 @@ fn format_record(
|
||||
mod test {
|
||||
#[test]
|
||||
fn test_examples() {
|
||||
use super::Format;
|
||||
use super::FormatPattern;
|
||||
use crate::test_examples;
|
||||
test_examples(Format {})
|
||||
test_examples(FormatPattern {})
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
mod command;
|
||||
|
||||
pub(crate) use command::Format;
|
||||
pub(crate) use command::FormatPattern;
|
||||
|
@ -6,24 +6,24 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-lang"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
name = "nu-cmd-lang"
|
||||
version = "0.88.1"
|
||||
version = "0.88.2"
|
||||
|
||||
[lib]
|
||||
bench = false
|
||||
|
||||
[dependencies]
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.1" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.88.1" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.1" }
|
||||
nu-utils = { path = "../nu-utils", version = "0.88.1" }
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.2" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.88.2" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.2" }
|
||||
nu-utils = { path = "../nu-utils", version = "0.88.2" }
|
||||
nu-ansi-term = "0.49.0"
|
||||
|
||||
fancy-regex = "0.11"
|
||||
itertools = "0.11"
|
||||
shadow-rs = { version = "0.24", default-features = false }
|
||||
fancy-regex = "0.12"
|
||||
itertools = "0.12"
|
||||
shadow-rs = { version = "0.26", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
shadow-rs = { version = "0.24", default-features = false }
|
||||
shadow-rs = { version = "0.26", default-features = false }
|
||||
|
||||
[features]
|
||||
mimalloc = []
|
||||
|
@ -19,11 +19,11 @@ impl Command for Alias {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("alias")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.required("name", SyntaxShape::String, "name of the alias")
|
||||
.required("name", SyntaxShape::String, "Name of the alias.")
|
||||
.required(
|
||||
"initial_value",
|
||||
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::Expression)),
|
||||
"equals sign followed by value",
|
||||
"Equals sign followed by value.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ impl Command for Collect {
|
||||
.required(
|
||||
"closure",
|
||||
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),
|
||||
"the closure to run once the stream is collected",
|
||||
"The closure to run once the stream is collected.",
|
||||
)
|
||||
.switch(
|
||||
"keep-env",
|
||||
|
@ -18,11 +18,11 @@ impl Command for Const {
|
||||
Signature::build("const")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("const_name", SyntaxShape::VarWithOptType, "constant name")
|
||||
.required("const_name", SyntaxShape::VarWithOptType, "Constant name.")
|
||||
.required(
|
||||
"initial_value",
|
||||
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::MathExpression)),
|
||||
"equals sign followed by constant value",
|
||||
"Equals sign followed by constant value.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ impl Command for Def {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("def")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.required("def_name", SyntaxShape::String, "command name")
|
||||
.required("params", SyntaxShape::Signature, "parameters")
|
||||
.required("block", SyntaxShape::Closure(None), "body of the definition")
|
||||
.required("def_name", SyntaxShape::String, "Command name.")
|
||||
.required("params", SyntaxShape::Signature, "Parameters.")
|
||||
.required("block", SyntaxShape::Closure(None), "Body of the definition.")
|
||||
.switch("env", "keep the environment defined inside the command", None)
|
||||
.switch("wrapped", "treat unknown flags and arguments as strings (requires ...rest-like parameter in signature)", None)
|
||||
.category(Category::Core)
|
||||
|
@ -290,7 +290,6 @@ fn describe_value(
|
||||
| Value::Date { .. }
|
||||
| Value::Range { .. }
|
||||
| Value::String { .. }
|
||||
| Value::MatchPattern { .. }
|
||||
| Value::Nothing { .. } => Value::record(
|
||||
record!(
|
||||
"type" => Value::string(value.get_type().to_string(), head),
|
||||
|
@ -25,7 +25,7 @@ impl Command for Do {
|
||||
.required(
|
||||
"closure",
|
||||
SyntaxShape::OneOf(vec![SyntaxShape::Closure(None), SyntaxShape::Any]),
|
||||
"the closure to run",
|
||||
"The closure to run.",
|
||||
)
|
||||
.input_output_types(vec![(Type::Any, Type::Any)])
|
||||
.switch(
|
||||
@ -53,7 +53,11 @@ impl Command for Do {
|
||||
"keep the environment defined inside the command",
|
||||
None,
|
||||
)
|
||||
.rest("rest", SyntaxShape::Any, "the parameter(s) for the closure")
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::Any,
|
||||
"The parameter(s) for the closure.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ impl Command for Echo {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("echo")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Any)])
|
||||
.rest("rest", SyntaxShape::Any, "the values to echo")
|
||||
.rest("rest", SyntaxShape::Any, "The values to echo.")
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ impl Command for ErrorMake {
|
||||
.required(
|
||||
"error_struct",
|
||||
SyntaxShape::Record(vec![]),
|
||||
"the error to create",
|
||||
"The error to create.",
|
||||
)
|
||||
.switch(
|
||||
"unspanned",
|
||||
|
@ -19,11 +19,11 @@ impl Command for ExportAlias {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("export alias")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.required("name", SyntaxShape::String, "name of the alias")
|
||||
.required("name", SyntaxShape::String, "Name of the alias.")
|
||||
.required(
|
||||
"initial_value",
|
||||
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::Expression)),
|
||||
"equals sign followed by value",
|
||||
"Equals sign followed by value.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -20,11 +20,11 @@ impl Command for ExportConst {
|
||||
Signature::build("export const")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("const_name", SyntaxShape::VarWithOptType, "constant name")
|
||||
.required("const_name", SyntaxShape::VarWithOptType, "Constant name.")
|
||||
.required(
|
||||
"initial_value",
|
||||
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::MathExpression)),
|
||||
"equals sign followed by constant value",
|
||||
"Equals sign followed by constant value.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ impl Command for ExportDef {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("export def")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.required("def_name", SyntaxShape::String, "command name")
|
||||
.required("params", SyntaxShape::Signature, "parameters")
|
||||
.required("block", SyntaxShape::Block, "body of the definition")
|
||||
.required("def_name", SyntaxShape::String, "Command name.")
|
||||
.required("params", SyntaxShape::Signature, "Parameters.")
|
||||
.required("block", SyntaxShape::Block, "Body of the definition.")
|
||||
.switch("env", "keep the environment defined inside the command", None)
|
||||
.switch("wrapped", "treat unknown flags and arguments as strings (requires ...rest-like parameter in signature)", None)
|
||||
.category(Category::Core)
|
||||
|
@ -17,8 +17,8 @@ impl Command for ExportExtern {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("export extern")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.required("def_name", SyntaxShape::String, "definition name")
|
||||
.required("params", SyntaxShape::Signature, "parameters")
|
||||
.required("def_name", SyntaxShape::String, "Definition name.")
|
||||
.required("params", SyntaxShape::Signature, "Parameters.")
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
|
@ -20,11 +20,11 @@ impl Command for ExportModule {
|
||||
Signature::build("export module")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("module", SyntaxShape::String, "module name or module path")
|
||||
.required("module", SyntaxShape::String, "Module name or module path.")
|
||||
.optional(
|
||||
"block",
|
||||
SyntaxShape::Block,
|
||||
"body of the module if 'module' parameter is not a path",
|
||||
"Body of the module if 'module' parameter is not a path.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ impl Command for ExportUse {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("export use")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.required("module", SyntaxShape::String, "Module or module file")
|
||||
.required("module", SyntaxShape::String, "Module or module file.")
|
||||
.optional(
|
||||
"members",
|
||||
SyntaxShape::Any,
|
||||
"Which members of the module to import",
|
||||
"Which members of the module to import.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ impl Command for Extern {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("extern")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.required("def_name", SyntaxShape::String, "definition name")
|
||||
.required("params", SyntaxShape::Signature, "parameters")
|
||||
.required("def_name", SyntaxShape::String, "Definition name.")
|
||||
.required("params", SyntaxShape::Signature, "Parameters.")
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
|
@ -25,14 +25,14 @@ impl Command for For {
|
||||
.required(
|
||||
"var_name",
|
||||
SyntaxShape::VarWithOptType,
|
||||
"name of the looping variable",
|
||||
"Name of the looping variable.",
|
||||
)
|
||||
.required(
|
||||
"range",
|
||||
SyntaxShape::Keyword(b"in".to_vec(), Box::new(SyntaxShape::Any)),
|
||||
"range of the loop",
|
||||
"Range of the loop.",
|
||||
)
|
||||
.required("block", SyntaxShape::Block, "the block to run")
|
||||
.required("block", SyntaxShape::Block, "The block to run.")
|
||||
.switch(
|
||||
"numbered",
|
||||
"return a numbered item ($it.index and $it.item)",
|
||||
|
@ -13,11 +13,11 @@ impl Command for Hide {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("hide")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.required("module", SyntaxShape::String, "Module or module file")
|
||||
.required("module", SyntaxShape::String, "Module or module file.")
|
||||
.optional(
|
||||
"members",
|
||||
SyntaxShape::Any,
|
||||
"Which members of the module to import",
|
||||
"Which members of the module to import.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ impl Command for HideEnv {
|
||||
.rest(
|
||||
"name",
|
||||
SyntaxShape::String,
|
||||
"environment variable names to hide",
|
||||
"Environment variable names to hide.",
|
||||
)
|
||||
.switch(
|
||||
"ignore-errors",
|
||||
|
@ -21,11 +21,11 @@ impl Command for If {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("if")
|
||||
.input_output_types(vec![(Type::Any, Type::Any)])
|
||||
.required("cond", SyntaxShape::MathExpression, "condition to check")
|
||||
.required("cond", SyntaxShape::MathExpression, "Condition to check.")
|
||||
.required(
|
||||
"then_block",
|
||||
SyntaxShape::Block,
|
||||
"block to run if check succeeds",
|
||||
"Block to run if check succeeds.",
|
||||
)
|
||||
.optional(
|
||||
"else_expression",
|
||||
@ -36,7 +36,7 @@ impl Command for If {
|
||||
SyntaxShape::Expression,
|
||||
])),
|
||||
),
|
||||
"expression or block to run if check fails",
|
||||
"Expression or block to run when the condition is false.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ impl Command for Let {
|
||||
Signature::build("let")
|
||||
.input_output_types(vec![(Type::Any, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("var_name", SyntaxShape::VarWithOptType, "variable name")
|
||||
.required("var_name", SyntaxShape::VarWithOptType, "Variable name.")
|
||||
.required(
|
||||
"initial_value",
|
||||
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::MathExpression)),
|
||||
"equals sign followed by value",
|
||||
"Equals sign followed by value.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ impl Command for Loop {
|
||||
Signature::build("loop")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("block", SyntaxShape::Block, "block to loop")
|
||||
.required("block", SyntaxShape::Block, "Block to loop.")
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
|
@ -20,11 +20,11 @@ impl Command for Match {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("match")
|
||||
.input_output_types(vec![(Type::Any, Type::Any)])
|
||||
.required("value", SyntaxShape::Any, "value to check")
|
||||
.required("value", SyntaxShape::Any, "Value to check.")
|
||||
.required(
|
||||
"match_block",
|
||||
SyntaxShape::MatchBlock,
|
||||
"block to run if check succeeds",
|
||||
"Block to run if check succeeds.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -20,11 +20,11 @@ impl Command for Module {
|
||||
Signature::build("module")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("module", SyntaxShape::String, "module name or module path")
|
||||
.required("module", SyntaxShape::String, "Module name or module path.")
|
||||
.optional(
|
||||
"block",
|
||||
SyntaxShape::Block,
|
||||
"body of the module if 'module' parameter is not a module path",
|
||||
"Body of the module if 'module' parameter is not a module path.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ impl Command for Mut {
|
||||
Signature::build("mut")
|
||||
.input_output_types(vec![(Type::Any, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("var_name", SyntaxShape::VarWithOptType, "variable name")
|
||||
.required("var_name", SyntaxShape::VarWithOptType, "Variable name.")
|
||||
.required(
|
||||
"initial_value",
|
||||
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::MathExpression)),
|
||||
"equals sign followed by value",
|
||||
"Equals sign followed by value.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -20,10 +20,10 @@ impl Command for OverlayHide {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("overlay hide")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.optional("name", SyntaxShape::String, "Overlay to hide")
|
||||
.optional("name", SyntaxShape::String, "Overlay to hide.")
|
||||
.switch(
|
||||
"keep-custom",
|
||||
"Keep all newly added commands and aliases in the next activated overlay",
|
||||
"Keep all newly added commands and aliases in the next activated overlay.",
|
||||
Some('k'),
|
||||
)
|
||||
.named(
|
||||
|
@ -21,7 +21,7 @@ impl Command for OverlayNew {
|
||||
Signature::build("overlay new")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("name", SyntaxShape::String, "Name of the overlay")
|
||||
.required("name", SyntaxShape::String, "Name of the overlay.")
|
||||
// TODO:
|
||||
// .switch(
|
||||
// "prefix",
|
||||
|
@ -27,12 +27,12 @@ impl Command for OverlayUse {
|
||||
.required(
|
||||
"name",
|
||||
SyntaxShape::String,
|
||||
"Module name to use overlay for",
|
||||
"Module name to use overlay for.",
|
||||
)
|
||||
.optional(
|
||||
"as",
|
||||
SyntaxShape::Keyword(b"as".to_vec(), Box::new(SyntaxShape::String)),
|
||||
"as keyword followed by a new name",
|
||||
"`as` keyword followed by a new name.",
|
||||
)
|
||||
.switch(
|
||||
"prefix",
|
||||
|
@ -20,12 +20,12 @@ impl Command for Register {
|
||||
.required(
|
||||
"plugin",
|
||||
SyntaxShape::Filepath,
|
||||
"path of executable for plugin",
|
||||
"Path of executable for plugin.",
|
||||
)
|
||||
.optional(
|
||||
"signature",
|
||||
SyntaxShape::Any,
|
||||
"Block with signature description as json object",
|
||||
"Block with signature description as json object.",
|
||||
)
|
||||
.named(
|
||||
"shell",
|
||||
|
@ -20,7 +20,11 @@ impl Command for Return {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("return")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Any)])
|
||||
.optional("return_value", SyntaxShape::Any, "optional value to return")
|
||||
.optional(
|
||||
"return_value",
|
||||
SyntaxShape::Any,
|
||||
"Optional value to return.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ impl Command for Try {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("try")
|
||||
.input_output_types(vec![(Type::Any, Type::Any)])
|
||||
.required("try_block", SyntaxShape::Block, "block to run")
|
||||
.required("try_block", SyntaxShape::Block, "Block to run.")
|
||||
.optional(
|
||||
"catch_block",
|
||||
SyntaxShape::Keyword(
|
||||
@ -31,7 +31,7 @@ impl Command for Try {
|
||||
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),
|
||||
])),
|
||||
),
|
||||
"block to run if try block fails",
|
||||
"Block to run if try block fails.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ impl Command for Use {
|
||||
Signature::build("use")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("module", SyntaxShape::String, "Module or module file")
|
||||
.required("module", SyntaxShape::String, "Module or module file.")
|
||||
.rest(
|
||||
"members",
|
||||
SyntaxShape::Any,
|
||||
"Which members of the module to import",
|
||||
"Which members of the module to import.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ impl Command for While {
|
||||
Signature::build("while")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("cond", SyntaxShape::MathExpression, "condition to check")
|
||||
.required("cond", SyntaxShape::MathExpression, "Condition to check.")
|
||||
.required(
|
||||
"block",
|
||||
SyntaxShape::Block,
|
||||
"block to loop if check succeeds",
|
||||
"Block to loop if check succeeds.",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
@ -278,9 +278,6 @@ impl<'a> std::fmt::Debug for DebuggableValue<'a> {
|
||||
let rec = val.collect().map_err(|_| std::fmt::Error)?;
|
||||
write!(f, "LazyRecord({:?})", DebuggableValue(&rec))
|
||||
}
|
||||
Value::MatchPattern { val, .. } => {
|
||||
write!(f, "MatchPattern({:?})", val)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,19 +5,19 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-color-confi
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
name = "nu-color-config"
|
||||
version = "0.88.1"
|
||||
version = "0.88.2"
|
||||
|
||||
[lib]
|
||||
bench = false
|
||||
|
||||
[dependencies]
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.1" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.2" }
|
||||
nu-ansi-term = "0.49.0"
|
||||
nu-utils = { path = "../nu-utils", version = "0.88.1" }
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.1" }
|
||||
nu-json = { path = "../nu-json", version = "0.88.1" }
|
||||
nu-utils = { path = "../nu-utils", version = "0.88.2" }
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.2" }
|
||||
nu-json = { path = "../nu-json", version = "0.88.2" }
|
||||
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
[dev-dependencies]
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.88.1" }
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.88.2" }
|
||||
|
@ -92,7 +92,7 @@ fn color_string_to_nustyle(color_string: String) -> Style {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use nu_ansi_term::{Color, Style};
|
||||
use nu_protocol::{Span, Value};
|
||||
use nu_protocol::{record, Span, Value};
|
||||
|
||||
#[test]
|
||||
fn test_color_string_to_nustyle_empty_string() {
|
||||
@ -120,13 +120,10 @@ mod tests {
|
||||
#[test]
|
||||
fn test_get_style_from_value() {
|
||||
// Test case 1: all values are valid
|
||||
let record = Record {
|
||||
cols: vec!["bg".to_string(), "fg".to_string(), "attr".to_string()],
|
||||
vals: vec![
|
||||
Value::string("red", Span::unknown()),
|
||||
Value::string("blue", Span::unknown()),
|
||||
Value::string("bold", Span::unknown()),
|
||||
],
|
||||
let record = record! {
|
||||
"bg" => Value::test_string("red"),
|
||||
"fg" => Value::test_string("blue"),
|
||||
"attr" => Value::test_string("bold"),
|
||||
};
|
||||
let expected_style = NuStyle {
|
||||
bg: Some("red".to_string()),
|
||||
@ -136,19 +133,15 @@ mod tests {
|
||||
assert_eq!(get_style_from_value(&record), Some(expected_style));
|
||||
|
||||
// Test case 2: no values are valid
|
||||
let record = Record {
|
||||
cols: vec!["invalid".to_string()],
|
||||
vals: vec![Value::nothing(Span::unknown())],
|
||||
let record = record! {
|
||||
"invalid" => Value::nothing(Span::test_data()),
|
||||
};
|
||||
assert_eq!(get_style_from_value(&record), None);
|
||||
|
||||
// Test case 3: some values are valid
|
||||
let record = Record {
|
||||
cols: vec!["bg".to_string(), "invalid".to_string()],
|
||||
vals: vec![
|
||||
Value::string("green", Span::unknown()),
|
||||
Value::nothing(Span::unknown()),
|
||||
],
|
||||
let record = record! {
|
||||
"bg" => Value::test_string("green"),
|
||||
"invalid" => Value::nothing(Span::unknown()),
|
||||
};
|
||||
let expected_style = NuStyle {
|
||||
bg: Some("green".to_string()),
|
||||
|
@ -131,8 +131,7 @@ impl<'a> StyleComputer<'a> {
|
||||
Value::Closure { .. }
|
||||
| Value::CustomValue { .. }
|
||||
| Value::Error { .. }
|
||||
| Value::LazyRecord { .. }
|
||||
| Value::MatchPattern { .. } => TextStyle::basic_left(),
|
||||
| Value::LazyRecord { .. } => TextStyle::basic_left(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ edition = "2021"
|
||||
license = "MIT"
|
||||
name = "nu-command"
|
||||
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-command"
|
||||
version = "0.88.1"
|
||||
version = "0.88.2"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@ -14,19 +14,19 @@ bench = false
|
||||
|
||||
[dependencies]
|
||||
nu-ansi-term = "0.49.0"
|
||||
nu-cmd-base = { path = "../nu-cmd-base", version = "0.88.1" }
|
||||
nu-color-config = { path = "../nu-color-config", version = "0.88.1" }
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.1" }
|
||||
nu-glob = { path = "../nu-glob", version = "0.88.1" }
|
||||
nu-json = { path = "../nu-json", version = "0.88.1" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.88.1" }
|
||||
nu-path = { path = "../nu-path", version = "0.88.1" }
|
||||
nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.88.1" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.1" }
|
||||
nu-system = { path = "../nu-system", version = "0.88.1" }
|
||||
nu-table = { path = "../nu-table", version = "0.88.1" }
|
||||
nu-term-grid = { path = "../nu-term-grid", version = "0.88.1" }
|
||||
nu-utils = { path = "../nu-utils", version = "0.88.1" }
|
||||
nu-cmd-base = { path = "../nu-cmd-base", version = "0.88.2" }
|
||||
nu-color-config = { path = "../nu-color-config", version = "0.88.2" }
|
||||
nu-engine = { path = "../nu-engine", version = "0.88.2" }
|
||||
nu-glob = { path = "../nu-glob", version = "0.88.2" }
|
||||
nu-json = { path = "../nu-json", version = "0.88.2" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.88.2" }
|
||||
nu-path = { path = "../nu-path", version = "0.88.2" }
|
||||
nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.88.2" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.88.2" }
|
||||
nu-system = { path = "../nu-system", version = "0.88.2" }
|
||||
nu-table = { path = "../nu-table", version = "0.88.2" }
|
||||
nu-term-grid = { path = "../nu-term-grid", version = "0.88.2" }
|
||||
nu-utils = { path = "../nu-utils", version = "0.88.2" }
|
||||
|
||||
alphanumeric-sort = "1.5"
|
||||
base64 = "0.21"
|
||||
@ -42,7 +42,7 @@ dialoguer = { default-features = false, features = ["fuzzy-select"], version = "
|
||||
digest = { default-features = false, version = "0.10" }
|
||||
dtparse = "2.0"
|
||||
encoding_rs = "0.8"
|
||||
fancy-regex = "0.11"
|
||||
fancy-regex = "0.12"
|
||||
filesize = "0.2"
|
||||
filetime = "0.2"
|
||||
fs_extra = "1.3"
|
||||
@ -50,9 +50,9 @@ htmlescape = "0.3"
|
||||
human-date-parser = "0.1.1"
|
||||
indexmap = "2.1"
|
||||
indicatif = "0.17"
|
||||
itertools = "0.11"
|
||||
itertools = "0.12"
|
||||
log = "0.4"
|
||||
lscolors = { version = "0.15", default-features = false, features = ["nu-ansi-term"] }
|
||||
lscolors = { version = "0.16", default-features = false, features = ["nu-ansi-term"] }
|
||||
md5 = { package = "md-5", version = "0.10" }
|
||||
miette = { version = "5.10", features = ["fancy-no-backtrace"] }
|
||||
mime = "0.3"
|
||||
@ -80,7 +80,7 @@ serde_json = "1.0"
|
||||
serde_urlencoded = "0.7"
|
||||
serde_yaml = "0.9"
|
||||
sha2 = "0.10"
|
||||
sysinfo = "0.29"
|
||||
sysinfo = "0.30"
|
||||
tabled = { version = "0.14.0", features = ["color"], default-features = false }
|
||||
terminal_size = "0.3"
|
||||
titlecase = "2.0"
|
||||
@ -104,9 +104,9 @@ winreg = "0.52"
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
libc = "0.2"
|
||||
umask = "2.1"
|
||||
nix = { version = "0.27", default-features = false, features = ["user"] }
|
||||
nix = { version = "0.27", default-features = false, features = ["user", "resource"] }
|
||||
|
||||
[target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "android"), not(target_os = "ios")))'.dependencies]
|
||||
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
|
||||
procfs = "0.16.0"
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies.trash]
|
||||
@ -122,7 +122,7 @@ features = [
|
||||
"Win32_Security",
|
||||
"Win32_System_Threading",
|
||||
]
|
||||
version = "0.48"
|
||||
version = "0.52"
|
||||
|
||||
[features]
|
||||
plugin = ["nu-parser/plugin"]
|
||||
@ -131,8 +131,8 @@ trash-support = ["trash"]
|
||||
which-support = ["which"]
|
||||
|
||||
[dev-dependencies]
|
||||
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.88.1" }
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.88.1" }
|
||||
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.88.2" }
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.88.2" }
|
||||
|
||||
dirs-next = "2.0"
|
||||
mockito = { version = "1.2", default-features = false }
|
||||
|
@ -40,7 +40,7 @@ impl Command for BytesAdd {
|
||||
(Type::Record(vec![]), Type::Record(vec![])),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("data", SyntaxShape::Binary, "the binary to add")
|
||||
.required("data", SyntaxShape::Binary, "The binary to add.")
|
||||
.named(
|
||||
"index",
|
||||
SyntaxShape::Int,
|
||||
@ -51,7 +51,7 @@ impl Command for BytesAdd {
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, add bytes to the data at the given cell paths",
|
||||
"For a data structure input, add bytes to the data at the given cell paths.",
|
||||
)
|
||||
.category(Category::Bytes)
|
||||
}
|
||||
|
@ -47,11 +47,11 @@ impl Command for BytesAt {
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
(Type::Record(vec![]), Type::Record(vec![])),
|
||||
])
|
||||
.required("range", SyntaxShape::Range, "the range to get bytes")
|
||||
.required("range", SyntaxShape::Range, "The range to get bytes.")
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, get bytes from data at the given cell paths",
|
||||
"For a data structure input, get bytes from data at the given cell paths.",
|
||||
)
|
||||
.category(Category::Bytes)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use nu_engine::eval_expression;
|
||||
use nu_engine::{eval_expression, CallExt};
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
@ -25,7 +25,7 @@ impl Command for BytesBuild {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("bytes build")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Binary)])
|
||||
.rest("rest", SyntaxShape::Any, "list of bytes")
|
||||
.rest("rest", SyntaxShape::Any, "List of bytes.")
|
||||
.category(Category::Bytes)
|
||||
}
|
||||
|
||||
@ -48,8 +48,7 @@ impl Command for BytesBuild {
|
||||
_input: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
let mut output = vec![];
|
||||
for expr in call.positional_iter() {
|
||||
let val = eval_expression(engine_state, stack, expr)?;
|
||||
for val in call.rest_iter_flattened(0, |expr| eval_expression(engine_state, stack, expr))? {
|
||||
match val {
|
||||
Value::Binary { mut val, .. } => output.append(&mut val),
|
||||
// Explicitly propagate errors instead of dropping them.
|
||||
|
@ -20,7 +20,7 @@ impl Command for BytesCollect {
|
||||
.optional(
|
||||
"separator",
|
||||
SyntaxShape::Binary,
|
||||
"optional separator to use when creating binary",
|
||||
"Optional separator to use when creating binary.",
|
||||
)
|
||||
.category(Category::Bytes)
|
||||
}
|
||||
|
@ -33,11 +33,11 @@ impl Command for BytesEndsWith {
|
||||
(Type::Record(vec![]), Type::Record(vec![])),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("pattern", SyntaxShape::Binary, "the pattern to match")
|
||||
.required("pattern", SyntaxShape::Binary, "The pattern to match.")
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, check if bytes at the given cell paths end with the pattern",
|
||||
"For a data structure input, check if bytes at the given cell paths end with the pattern.",
|
||||
)
|
||||
.category(Category::Bytes)
|
||||
}
|
||||
|
@ -41,12 +41,12 @@ impl Command for BytesIndexOf {
|
||||
.required(
|
||||
"pattern",
|
||||
SyntaxShape::Binary,
|
||||
"the pattern to find index of",
|
||||
"The pattern to find index of.",
|
||||
)
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, find the indexes at the given cell paths",
|
||||
"For a data structure input, find the indexes at the given cell paths.",
|
||||
)
|
||||
.switch("all", "returns all matched index", Some('a'))
|
||||
.switch("end", "search from the end of the binary", Some('e'))
|
||||
|
@ -29,7 +29,7 @@ impl Command for BytesLen {
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, find the length of data at the given cell paths",
|
||||
"For a data structure input, find the length of data at the given cell paths.",
|
||||
)
|
||||
.category(Category::Bytes)
|
||||
}
|
||||
|
@ -35,11 +35,11 @@ impl Command for BytesRemove {
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
(Type::Record(vec![]), Type::Record(vec![])),
|
||||
])
|
||||
.required("pattern", SyntaxShape::Binary, "the pattern to find")
|
||||
.required("pattern", SyntaxShape::Binary, "The pattern to find.")
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, remove bytes from data at the given cell paths",
|
||||
"For a data structure input, remove bytes from data at the given cell paths.",
|
||||
)
|
||||
.switch("end", "remove from end of binary", Some('e'))
|
||||
.switch("all", "remove occurrences of finding binary", Some('a'))
|
||||
@ -105,6 +105,13 @@ impl Command for BytesRemove {
|
||||
vec![0x10, 0xAA, 0x10, 0xBB, 0xCC, 0xAA],
|
||||
)),
|
||||
},
|
||||
Example {
|
||||
description: "Remove find binary from end not found",
|
||||
example: "0x[10 AA 10 BB CC AA 10] | bytes remove --end 0x[11]",
|
||||
result: Some(Value::test_binary (
|
||||
vec![0x10, 0xAA, 0x10, 0xBB, 0xCC, 0xAA, 0x10],
|
||||
)),
|
||||
},
|
||||
Example {
|
||||
description: "Remove all occurrences of find binary in table",
|
||||
example: "[[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes remove 0x[11] ColA ColC",
|
||||
@ -159,8 +166,11 @@ fn remove_impl(input: &[u8], arg: &Arguments, span: Span) -> Value {
|
||||
}
|
||||
// append the remaining thing to result, this can be happening when
|
||||
// we have something to remove and remove_all is False.
|
||||
let mut remain = input[..left as usize].iter().copied().rev().collect();
|
||||
result.append(&mut remain);
|
||||
// check if the left is positive, if it is not, we don't need to append anything.
|
||||
if left > 0 {
|
||||
let mut remain = input[..left as usize].iter().copied().rev().collect();
|
||||
result.append(&mut remain);
|
||||
}
|
||||
result = result.into_iter().rev().collect();
|
||||
Value::binary(result, span)
|
||||
} else {
|
||||
|
@ -36,12 +36,12 @@ impl Command for BytesReplace {
|
||||
(Type::Record(vec![]), Type::Record(vec![])),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("find", SyntaxShape::Binary, "the pattern to find")
|
||||
.required("replace", SyntaxShape::Binary, "the replacement pattern")
|
||||
.required("find", SyntaxShape::Binary, "The pattern to find.")
|
||||
.required("replace", SyntaxShape::Binary, "The replacement pattern.")
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, replace bytes in data at the given cell paths",
|
||||
"For a data structure input, replace bytes in data at the given cell paths.",
|
||||
)
|
||||
.switch("all", "replace all occurrences of find binary", Some('a'))
|
||||
.category(Category::Bytes)
|
||||
|
@ -26,7 +26,7 @@ impl Command for BytesReverse {
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, reverse data at the given cell paths",
|
||||
"For a data structure input, reverse data at the given cell paths.",
|
||||
)
|
||||
.category(Category::Bytes)
|
||||
}
|
||||
|
@ -35,11 +35,11 @@ impl Command for BytesStartsWith {
|
||||
(Type::Record(vec![]), Type::Record(vec![])),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("pattern", SyntaxShape::Binary, "the pattern to match")
|
||||
.required("pattern", SyntaxShape::Binary, "The pattern to match.")
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, check if bytes at the given cell paths start with the pattern",
|
||||
"For a data structure input, check if bytes at the given cell paths start with the pattern.",
|
||||
)
|
||||
.category(Category::Bytes)
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ impl Command for Histogram {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("histogram")
|
||||
.input_output_types(vec![(Type::List(Box::new(Type::Any)), Type::Table(vec![])),])
|
||||
.optional("column-name", SyntaxShape::String, "column name to calc frequency, no need to provide if input is just a list")
|
||||
.optional("frequency-column-name", SyntaxShape::String, "histogram's frequency column, default to be frequency column output")
|
||||
.optional("column-name", SyntaxShape::String, "Column name to calc frequency, no need to provide if input is a list.")
|
||||
.optional("frequency-column-name", SyntaxShape::String, "Histogram's frequency column, default to be frequency column output.")
|
||||
.named("percentage-type", SyntaxShape::String, "percentage calculate method, can be 'normalize' or 'relative', in 'normalize', defaults to be 'normalize'", Some('t'))
|
||||
.category(Category::Chart)
|
||||
}
|
||||
@ -258,16 +258,16 @@ fn histogram_impl(
|
||||
result.push((
|
||||
count, // attach count first for easily sorting.
|
||||
Value::record(
|
||||
Record {
|
||||
cols: result_cols.clone(),
|
||||
vals: vec![
|
||||
Record::from_raw_cols_vals(
|
||||
result_cols.clone(),
|
||||
vec![
|
||||
val.into_value(),
|
||||
Value::int(count, span),
|
||||
Value::float(quantile, span),
|
||||
Value::string(percentage, span),
|
||||
Value::string(freq, span),
|
||||
],
|
||||
},
|
||||
),
|
||||
span,
|
||||
),
|
||||
));
|
||||
|
@ -44,7 +44,7 @@ impl Command for SubCommand {
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, convert data at the given cell paths",
|
||||
"For a data structure input, convert data at the given cell paths.",
|
||||
)
|
||||
.category(Category::Conversions)
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ impl Command for SubCommand {
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, convert data at the given cell paths",
|
||||
"For a data structure input, convert data at the given cell paths.",
|
||||
)
|
||||
.category(Category::Conversions)
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ impl Command for SubCommand {
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, convert data at the given cell paths",
|
||||
"For a data structure input, convert data at the given cell paths.",
|
||||
)
|
||||
.category(Category::Conversions)
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ impl Command for SubCommand {
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, convert data at the given cell paths",
|
||||
"For a data structure input, convert data at the given cell paths.",
|
||||
)
|
||||
.category(Category::Conversions)
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ impl Command for SubCommand {
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, convert data at the given cell paths",
|
||||
"For a data structure input, convert data at the given cell paths.",
|
||||
)
|
||||
.category(Category::Conversions)
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ impl Command for SubCommand {
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, convert data at the given cell paths",
|
||||
"For a data structure input, convert data at the given cell paths.",
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Conversions)
|
||||
|
@ -81,7 +81,7 @@ impl Command for SubCommand {
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, convert data at the given cell paths",
|
||||
"For a data structure input, convert data at the given cell paths.",
|
||||
)
|
||||
.category(Category::Conversions)
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ impl Command for SubCommand {
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, convert data at the given cell paths",
|
||||
"For a data structure input, convert data at the given cell paths.",
|
||||
)
|
||||
.named(
|
||||
"decimals",
|
||||
|
@ -25,7 +25,7 @@ impl Command for IntoSqliteDb {
|
||||
.required(
|
||||
"file_name",
|
||||
SyntaxShape::String,
|
||||
"Specify the filename to save the database to",
|
||||
"Specify the filename to save the database to.",
|
||||
)
|
||||
.named(
|
||||
"table_name",
|
||||
@ -260,7 +260,6 @@ fn nu_value_to_string(value: Value, separator: &str) -> String {
|
||||
Value::Binary { val, .. } => format!("{val:?}"),
|
||||
Value::CellPath { val, .. } => val.to_string(),
|
||||
Value::CustomValue { val, .. } => val.value_string(),
|
||||
Value::MatchPattern { val, .. } => format!("{:?}", val),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ impl Command for QueryDb {
|
||||
.required(
|
||||
"SQL",
|
||||
SyntaxShape::String,
|
||||
"SQL to execute against the database",
|
||||
"SQL to execute against the database.",
|
||||
)
|
||||
.category(Category::Database)
|
||||
}
|
||||
|
@ -499,13 +499,7 @@ pub fn convert_sqlite_row_to_nu_value(row: &Row, span: Span, column_names: Vec<S
|
||||
vals.push(val);
|
||||
}
|
||||
|
||||
Value::record(
|
||||
Record {
|
||||
cols: column_names,
|
||||
vals,
|
||||
},
|
||||
span,
|
||||
)
|
||||
Value::record(Record::from_raw_cols_vals(column_names, vals), span)
|
||||
}
|
||||
|
||||
pub fn convert_sqlite_value_to_nu_value(value: ValueRef, span: Span) -> Value {
|
||||
|
@ -22,7 +22,7 @@ impl Command for SubCommand {
|
||||
Signature::build("date to-timezone")
|
||||
.input_output_types(vec![(Type::Date, Type::Date), (Type::String, Type::Date)])
|
||||
.allow_variants_without_examples(true) // https://github.com/nushell/nushell/issues/7032
|
||||
.required("time zone", SyntaxShape::String, "time zone description")
|
||||
.required("time zone", SyntaxShape::String, "Time zone description.")
|
||||
.category(Category::Date)
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ impl Command for Ast {
|
||||
.required(
|
||||
"pipeline",
|
||||
SyntaxShape::String,
|
||||
"the pipeline to print the ast for",
|
||||
"The pipeline to print the ast for.",
|
||||
)
|
||||
.switch("json", "serialize to json", Some('j'))
|
||||
.switch("minify", "minify the nuon or json output", Some('m'))
|
||||
|
@ -23,7 +23,7 @@ impl Command for Explain {
|
||||
.required(
|
||||
"closure",
|
||||
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),
|
||||
"the closure to run",
|
||||
"The closure to run.",
|
||||
)
|
||||
.input_output_types(vec![(Type::Any, Type::Any), (Type::Nothing, Type::Any)])
|
||||
.allow_variants_without_examples(true)
|
||||
@ -191,6 +191,24 @@ fn get_arguments(engine_state: &EngineState, stack: &mut Stack, call: Call) -> V
|
||||
let arg_value_name_span_start = evaled_span.start as i64;
|
||||
let arg_value_name_span_end = evaled_span.end as i64;
|
||||
|
||||
let record = record! {
|
||||
"arg_type" => Value::string(arg_type, span),
|
||||
"name" => Value::string(arg_value_name, inner_expr.span),
|
||||
"type" => Value::string(arg_value_type, span),
|
||||
"span_start" => Value::int(arg_value_name_span_start, span),
|
||||
"span_end" => Value::int(arg_value_name_span_end, span),
|
||||
};
|
||||
arg_value.push(Value::record(record, inner_expr.span));
|
||||
}
|
||||
Argument::Spread(inner_expr) => {
|
||||
let arg_type = "spread";
|
||||
let evaluated_expression = get_expression_as_value(engine_state, stack, inner_expr);
|
||||
let arg_value_name = debug_string_without_formatting(&evaluated_expression);
|
||||
let arg_value_type = &evaluated_expression.get_type().to_string();
|
||||
let evaled_span = evaluated_expression.span();
|
||||
let arg_value_name_span_start = evaled_span.start as i64;
|
||||
let arg_value_name_span_end = evaled_span.end as i64;
|
||||
|
||||
let record = record! {
|
||||
"arg_type" => Value::string(arg_type, span),
|
||||
"name" => Value::string(arg_value_name, inner_expr.span),
|
||||
@ -259,6 +277,5 @@ pub fn debug_string_without_formatting(value: &Value) -> String {
|
||||
Value::Binary { val, .. } => format!("{val:?}"),
|
||||
Value::CellPath { val, .. } => val.to_string(),
|
||||
Value::CustomValue { val, .. } => val.value_string(),
|
||||
Value::MatchPattern { val, .. } => format!("{:?}", val),
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use nu_protocol::{
|
||||
record, Category, Example, IntoPipelineData, LazyRecord, PipelineData, Record, ShellError,
|
||||
Signature, Span, Type, Value,
|
||||
};
|
||||
use sysinfo::{Pid, PidExt, ProcessExt, ProcessRefreshKind, RefreshKind, System, SystemExt};
|
||||
use sysinfo::{MemoryRefreshKind, Pid, ProcessRefreshKind, RefreshKind, System};
|
||||
const ENV_PATH_SEPARATOR_CHAR: char = {
|
||||
#[cfg(target_family = "windows")]
|
||||
{
|
||||
@ -98,8 +98,9 @@ impl LazySystemInfoRecord {
|
||||
}
|
||||
"system" => {
|
||||
// only get information requested
|
||||
let system_opt =
|
||||
SystemOpt::from((system_option, || RefreshKind::new().with_memory()));
|
||||
let system_opt = SystemOpt::from((system_option, || {
|
||||
RefreshKind::new().with_memory(MemoryRefreshKind::everything())
|
||||
}));
|
||||
|
||||
let system = system_opt.get_system();
|
||||
|
||||
@ -135,53 +136,66 @@ impl LazySystemInfoRecord {
|
||||
"virtual_memory" => Value::filesize(p.virtual_memory() as i64, self.span),
|
||||
"status" => Value::string(p.status().to_string(), self.span),
|
||||
"root" => {
|
||||
if let Some(filename) = p.exe().parent() {
|
||||
Value::string(filename.to_string_lossy().to_string(), self.span)
|
||||
if let Some(path) = p.exe().and_then(|p| p.parent()) {
|
||||
Value::string(path.to_string_lossy().to_string(), self.span)
|
||||
} else {
|
||||
Value::nothing(self.span)
|
||||
}
|
||||
},
|
||||
"cwd" => Value::string(p.cwd().to_string_lossy().to_string(), self.span),
|
||||
"exe_path" => Value::string(p.exe().to_string_lossy().to_string(), self.span),
|
||||
"cwd" => {
|
||||
if let Some(path) = p.cwd() {
|
||||
Value::string(path.to_string_lossy().to_string(), self.span)
|
||||
}else{
|
||||
Value::nothing(self.span)
|
||||
}
|
||||
},
|
||||
"exe_path" => {
|
||||
if let Some(path)= p.exe() {
|
||||
Value::string(path.to_string_lossy().to_string(), self.span)
|
||||
}else{
|
||||
Value::nothing(self.span)
|
||||
}
|
||||
},
|
||||
"command" => Value::string(p.cmd().join(" "), self.span),
|
||||
"name" => Value::string(p.name().to_string(), self.span),
|
||||
"environment" => {
|
||||
let mut env_rec = Record::new();
|
||||
for val in p.environ() {
|
||||
if let Some((key, value)) = val.split_once('=') {
|
||||
let is_env_var_a_list = {
|
||||
"environment" => {
|
||||
let mut env_rec = Record::new();
|
||||
for val in p.environ() {
|
||||
if let Some((key, value)) = val.split_once('=') {
|
||||
let is_env_var_a_list = {
|
||||
{
|
||||
#[cfg(target_family = "windows")]
|
||||
{
|
||||
#[cfg(target_family = "windows")]
|
||||
{
|
||||
key == "Path" || key == "PATHEXT" || key == "PSMODULEPATH" || key == "PSModulePath"
|
||||
}
|
||||
#[cfg(not(target_family = "windows"))]
|
||||
{
|
||||
key == "PATH" || key == "DYLD_FALLBACK_LIBRARY_PATH"
|
||||
}
|
||||
key == "Path" || key == "PATHEXT" || key == "PSMODULEPATH" || key == "PSModulePath"
|
||||
}
|
||||
#[cfg(not(target_family = "windows"))]
|
||||
{
|
||||
key == "PATH" || key == "DYLD_FALLBACK_LIBRARY_PATH"
|
||||
}
|
||||
};
|
||||
if is_env_var_a_list {
|
||||
let items = value.split(ENV_PATH_SEPARATOR_CHAR).map(|r| Value::string(r.to_string(), self.span)).collect::<Vec<_>>();
|
||||
env_rec.push(key.to_string(), Value::list(items, self.span));
|
||||
} else if key == "LS_COLORS" { // LS_COLORS is a special case, it's a colon separated list of key=value pairs
|
||||
let items = value.split(':').map(|r| Value::string(r.to_string(), self.span)).collect::<Vec<_>>();
|
||||
env_rec.push(key.to_string(), Value::list(items, self.span));
|
||||
} else {
|
||||
env_rec.push(key.to_string(), Value::string(value.to_string(), self.span));
|
||||
}
|
||||
};
|
||||
if is_env_var_a_list {
|
||||
let items = value.split(ENV_PATH_SEPARATOR_CHAR).map(|r| Value::string(r.to_string(), self.span)).collect::<Vec<_>>();
|
||||
env_rec.push(key.to_string(), Value::list(items, self.span));
|
||||
} else if key == "LS_COLORS" { // LS_COLORS is a special case, it's a colon separated list of key=value pairs
|
||||
let items = value.split(':').map(|r| Value::string(r.to_string(), self.span)).collect::<Vec<_>>();
|
||||
env_rec.push(key.to_string(), Value::list(items, self.span));
|
||||
} else {
|
||||
env_rec.push(key.to_string(), Value::string(value.to_string(), self.span));
|
||||
}
|
||||
}
|
||||
Value::record(env_rec, self.span)
|
||||
},
|
||||
}
|
||||
Value::record(env_rec, self.span)
|
||||
},
|
||||
},
|
||||
self.span,
|
||||
))
|
||||
} else {
|
||||
// If we can't get the process information, just return the system information
|
||||
// only get information requested
|
||||
let system_opt =
|
||||
SystemOpt::from((system_option, || RefreshKind::new().with_memory()));
|
||||
let system_opt = SystemOpt::from((system_option, || {
|
||||
RefreshKind::new().with_memory(MemoryRefreshKind::everything())
|
||||
}));
|
||||
let system = system_opt.get_system();
|
||||
|
||||
Ok(Value::record(
|
||||
@ -228,7 +242,7 @@ impl<'a> LazyRecord<'a> for LazySystemInfoRecord {
|
||||
.without_disk_usage()
|
||||
.without_user(),
|
||||
)
|
||||
.with_memory();
|
||||
.with_memory(MemoryRefreshKind::everything());
|
||||
// only get information requested
|
||||
let system = System::new_with_specifics(rk);
|
||||
|
||||
|
@ -25,7 +25,7 @@ impl Command for Metadata {
|
||||
.optional(
|
||||
"expression",
|
||||
SyntaxShape::Any,
|
||||
"the expression you want metadata for",
|
||||
"The expression you want metadata for.",
|
||||
)
|
||||
.category(Category::Debug)
|
||||
}
|
||||
@ -86,6 +86,12 @@ impl Command for Metadata {
|
||||
PipelineMetadata {
|
||||
data_source: DataSource::HtmlThemes,
|
||||
} => record.push("source", Value::string("into html --list", head)),
|
||||
PipelineMetadata {
|
||||
data_source: DataSource::FilePath(path),
|
||||
} => record.push(
|
||||
"source",
|
||||
Value::string(path.to_string_lossy().to_string(), head),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,6 +139,12 @@ fn build_metadata_record(arg: &Value, metadata: Option<&PipelineMetadata>, head:
|
||||
PipelineMetadata {
|
||||
data_source: DataSource::HtmlThemes,
|
||||
} => record.push("source", Value::string("into html --list", head)),
|
||||
PipelineMetadata {
|
||||
data_source: DataSource::FilePath(path),
|
||||
} => record.push(
|
||||
"source",
|
||||
Value::string(path.to_string_lossy().to_string(), head),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ impl Command for TimeIt {
|
||||
.required(
|
||||
"command",
|
||||
SyntaxShape::OneOf(vec![SyntaxShape::Block, SyntaxShape::Expression]),
|
||||
"the command or block to run",
|
||||
"The command or block to run.",
|
||||
)
|
||||
.input_output_types(vec![
|
||||
(Type::Any, Type::Duration),
|
||||
|
@ -22,7 +22,7 @@ impl Command for ViewSource {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("view source")
|
||||
.input_output_types(vec![(Type::Nothing, Type::String)])
|
||||
.required("item", SyntaxShape::Any, "name or block to view")
|
||||
.required("item", SyntaxShape::Any, "Name or block to view.")
|
||||
.category(Category::Debug)
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user